* * *

Author Topic: [SOLVED] Verbosity...  (Read 3338 times)

GypsyPrince

  • New member
  • *
  • Posts: 34
[SOLVED] Verbosity...
« on: July 01, 2018, 12:00:14 am »
1.) Can FPC expand the main program block entry point and terminator?

Current:
----------------
Begin
    // Put program code here...
End.


Proposed:
----------------
Function Main(): Integer;
Begin
    // Put program code here...
End Main.

And frankly, I'd also be happy if the "Begin" statement was just completely removed.

2.) One reason I am working to transition from Visual Basic .NET to Lazarus is that Lazarus matches VB in its verbosity. Is there any possibility that we can take it just a little bit further with the "End" statements?

Every structure block is terminated with the "end;" statement.

Can FPC extend the to include the block type of which they are terminating?

Examples:
-------------------------------------
End Function;
End Procedure;
End If;
End Try;
End Case;

etc.

"While-do", "Repeat-until", and "For-do" loop structures should all terminate with "End Loop;".

In large tutorial examples I've seen containing several nested blocks, it is difficult to determine which "End;" terminator goes with which structure block.

Again, I'd be happy if the "Begin" statement was just completely removed.

I like verbosity. It forces the programmer to make fewer mistakes.

Is this a doable thing... at least as an option whereby programmers who like the current way can still use only the "End;" terminator?

This is just a wish. If these two ideas have already been pondered and rejected, I'll understand.

Thanx!
« Last Edit: July 02, 2018, 05:11:24 pm by GypsyPrince »
May the mass * acceleration be with you!

RAW

  • Hero Member
  • *****
  • Posts: 672
Re: [Feature Request] Verbosity...
« Reply #1 on: July 01, 2018, 01:05:05 am »
First thought: WTF ???
Second: It's open source... you can do with it whatever you like [almost]...    :)
Windows 7 Pro (x64 Sp1) And Windows XP Pro (x86 Sp3) - LAZARUS 1.8.4 FPC 3.0.4 // 1.7 FPC 3.1.1

Phil

  • Hero Member
  • *****
  • Posts: 2749
Re: [Feature Request] Verbosity...
« Reply #2 on: July 01, 2018, 02:04:39 am »
This is just a wish. If these two ideas have already been pondered and rejected, I'll understand.

Not sure why anyone would want _more_ verbosity, since Pascal is already quite verbose, but if you prefer that syntax, you might want to stay with VB.NET. You do realized that VB.NET is cross-platform, right? Mono on Mac and Linux has always included a VB.NET compiler and Microsoft's free and relatively new IDE, Visual Studio for Mac, now includes Microsoft's VB.NET compiler (vbc) as well as the older Mono compiler (vbnc).

If you want to learn Pascal but retain a bit of the flavor of VB, you can always include the missing keyword as a comment, eg,

function HeyThere : Boolean;
begin
end;  {function}

Although I think repeating the name of the function makes more sense:

end;  {HeyThere}

For keeping track of begin/end, just make sure you indent properly. Maybe the tutorial you looked at wasn't indented quite right.

GypsyPrince

  • New member
  • *
  • Posts: 34
Re: [Feature Request] Verbosity...
« Reply #3 on: July 01, 2018, 03:09:27 am »
Phil ~
1.) I no longer want to use the .NET or Mono frameworks, both of which are just virtual machines. I want native code.
2.) I asked if there was a way to make the extra verbosity OPTIONAL. If you don't like a feature, don't use it. And don't question someone else wanting to use it/ Life is really simpler that way.

RAW ~
I don't yet have the skill in Pascal to do what I want with the language/compiler.
If I ever win the lottery, the first thing I buy will not be a large house or exotic car. Instead, I while hire a team to develop an open source language, IDE, and compiler for me. It will be something similar to Visual Basic and Pascal having a baby... LOL
May the mass * acceleration be with you!

ASBzone

  • Jr. Member
  • **
  • Posts: 78
  • Automation leads to relaxation...
    • BrainWaveCC Utilities
Re: [Feature Request] Verbosity...
« Reply #4 on: July 01, 2018, 06:01:18 am »

Can FPC extend the to include the block type of which they are terminating?

Examples:
-------------------------------------
End Function;
End Procedure;
End If;
End Try;
End Case;

etc.

"While-do", "Repeat-until", and "For-do" loop structures should all terminate with "End Loop;".


It is kind of ironic to see you (rightfully) condemn programming language bashing in one thread, but pursue the "hey, let's see some changes in this language that I have not gotten familiar with as yet" in this thread.   :D    Not quite the same as bashing, but comes pretty close.

In any event, I would suggest using comments for increased verbosity.   Of course, the compiler is not going to aid you in any way with these, but you could pursue the following effective immediately.

End {Function};
End {Procedure};
End {If};
End {Try};
End {Case};

Modula-2, Oberon and Oberon-2 -- which are Pascalish languages (or, more accurately, Wirthian languages) -- do support the following:

PROCEDURE SomeName
...
END SomeName


https://www.modula2.org/reference/proceduredeclarations.php
https://www.inf.ethz.ch/personal/wirth/Oberon/Oberon07.Report.pdf
https://en.wikipedia.org/wiki/Oberon-2#Syntax


But Pascal itself doesn't.   You could still use the same technique above (i.e. END {SomeName};) although the Lazarus IDE helps keep you straight on which procedure or function you are in, especially if you look at the various UI options.
-ASB: https://www.BrainWaveCC.com

Lazarus 1.8.4 + FPC 3.0.4 (32-bit w/64-bit cross-compile)
Occasional testing of NewPascal
Windows 10 Pro x64, Version 1803 (Build 17134.228)

(Technically, I logon to these forums from multiple versions of Windows Pro/Enterprise...)

GypsyPrince

  • New member
  • *
  • Posts: 34
Re: [Feature Request] Verbosity...
« Reply #5 on: July 01, 2018, 06:17:23 am »
"It is kind of ironic to see you (rightfully) condemn programming language bashing in one thread, but pursue the "hey, let's see some changes in this language that I have not gotten familiar with as yet" in this thread.   :D    Not quite the same as bashing, but comes pretty close."

Soooooooo... you think asking for an option, not a complete change, but an option to do something a different way while leaving the ability for others to keep doing it the current way comes even remotely close to "bashing" said language? Wow! What a grasp of the English language because the English I learned in school - the two concepts come nowhere even close to being related. But keep on with that if it makes you feel better.

Like I told the other guy, if you don't like the feature. just don't use it. That way it doesn't affect you. And if it doesn't affect you, then it's none of your business. See how simple life is. Now, if I wanted to remove an existing feature that you happen to like, then you might have proper cause to chime in with your opinion. But in this case... not so much. Don't like a feature request, don't use it. But don't bash someone else asking for it or tell them they'd be better off doing it this way or that. Since you're not a developer of Lazarus, my guess is the request wasn't directed at you, and again, not your place to chime in.
May the mass * acceleration be with you!

Thaddy

  • Hero Member
  • *****
  • Posts: 6754
Re: [Feature Request] Verbosity...
« Reply #6 on: July 01, 2018, 08:39:08 am »
Well, how about:
Code: Pascal  [Select]
  1. {$macro on}{$Define End_Function:=end}{$Define End_Procedure:=End}
  2. {$Define End_If := End}{$Define End_Try:= End}{$Define End_Case := End}
  3. procedure testme;
  4. var i integer = 0;
  5. begin
  6.   if true then
  7.     case i of
  8.     1:;
  9.     2:;
  10.     3:;
  11.     end_case;
  12.   end_if;
  13. end_procedure;
  14. begin
  15. end.
Note that would be only you using it....This is not VB. A.k.a. VerBose
« Last Edit: July 01, 2018, 08:56:44 am by Thaddy »
Ada's daddy wrote this:"Fools are my theme, let satire be my song."

Handoko

  • Hero Member
  • *****
  • Posts: 2580
  • My goal: build my own game engine using Lazarus
Re: [Feature Request] Verbosity...
« Reply #7 on: July 01, 2018, 08:52:28 am »
What about:

Code: Pascal  [Select]
  1. procedure testme;
  2. begin
  3.   if true then
  4.     case integer of
  5.     a:;
  6.     b:;
  7.     c:;
  8.     end; // case
  9.   end; // if
  10. end; // procedure
  11.  
  12. begin
  13. end.

GypsyPrince

  • New member
  • *
  • Posts: 34
Re: [Feature Request] Verbosity...
« Reply #8 on: July 01, 2018, 10:17:35 am »
Part of my thinking here (or lack thereof, really LOL) is that as Microsoft decreases its development of Visual Basic, there will be a lot of VB users looking for a replacement.  So far, Delphi and Lazarus are the closest equivalents to VB as far as its features vs. its ease of use. Other supposed VB alternatives I've tried just don't even come close to what VB, Lazarus, or Delphi can do. I was just thinking that, the option for syntax a bit more similar to VB's might go a long way to attract those users to Lazarus/Free Pascal. You'd already win them over with the functionality and features in Lazarus, which they'd naturally learn as they go. But as perception is reality, it is the syntax that always gives new users performance anxiety, fills them with doubts, and frightens them away from a new language.  I used to be young and quick to learn. But now I'm old, feeble, and slow on the uptake. So, I learn better and faster with things which are at least a bit familiar to me. Because familiarity makes me feel more comfortable on the surface, I become more curious about other unfamiliar aspects and features of the language and begin to dabble with them.  Free Pascal shouldn't be a syntactic VB clone, by any means. It would just be nice if it were a bit more similar is all I'm saying. So far, it's proving to be a bad-ass development environment.
« Last Edit: July 01, 2018, 05:04:26 pm by GypsyPrince »
May the mass * acceleration be with you!

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6510
Re: [Feature Request] Verbosity...
« Reply #9 on: July 01, 2018, 02:46:23 pm »
1.) Can FPC expand the main program block entry point and terminator?

No. Personally I don't see any benefit in this, other than removing one identifier (Main) from the usable identifier space.

And frankly, I'd also be happy if the "Begin" statement was just completely removed.

Can FPC extend the to include the block type of which they are terminating?

(and END becoming mandatory) Me too, but then it is no longer Pascal, but closer to Modula2.

Quote
2.) One reason I am working to transition from Visual Basic .NET to Lazarus is that Lazarus matches VB in its verbosity. Is there any possibility that we can take it just a little bit further with the "End" statements?

I'd like it, but only for the END function/procedure statements. Major mistakes in the block structure are more likely to be detected and localized at such END xxx point. Doing it for other statements too is fine, but should be voluntary, not mandatory. In many cases you don't want it since it hampers refactoring. 

Modula2 (Pascal's successor) required to end with the function name, so

Code: [Select]
PROCEDURE SOME;
BEGIN
END 'SOME';

And while that was useful in some far fetched cases with nested procedures, in practice it was an enormous strain on refactoring. Though I assume nowadays with IDE identifier rename this should be a bit less.

Quote
"While-do", "Repeat-until", and "For-do" loop structures should all terminate with "End Loop;".

Then I would go for Modula2, where everything but straight for is a LOOP..END with a manual IF  THEN EXIT as terminator

In large tutorial examples I've seen containing several nested blocks, it is difficult to determine which "End;" terminator goes with which structure block.

Indenting, IDE tools there is even a setting to give the various levels a different colour (not perfect, but can help).
I use that, strangely enough, with Verilog. My Pascal usually is never insanely nested.

But this is all in some hypothetical case where we would start over with a new language. We are PASCAL, and we are backwards compatible with enormous codebases in both pure pascal and Delphi. Minor rearrangements that break code or splitting in radically different dialects mode is just not worth it. I would abolish OBJFPC if I had the chance
« Last Edit: July 01, 2018, 04:35:39 pm by marcov »

kupferstecher

  • Full Member
  • ***
  • Posts: 218
Re: [Feature Request] Verbosity...
« Reply #10 on: July 01, 2018, 03:40:29 pm »
Minor rearrangements that break code or splitting in radically different dialects mode is just not worth it. I would abolish OBJFPC if I had the chance
How are the compile modes realized? Do they have their own units, are there ifdef -orgies or... ?
« Last Edit: July 01, 2018, 03:58:23 pm by kupferstecher »

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6510
Re: [Feature Request] Verbosity...
« Reply #11 on: July 01, 2018, 03:46:16 pm »
How are the compile modes realized? Do they have their own units, are there ifdef-orgies or... ?

Afaik the modes are partially implemented by differing initialization of the parser for the given module, and a collection/set of suboptions that are tested with IF's yes (but since multiple modes can define same suboptions, you only need one test).

Mode objfpc is mostly different in generics and the @ for procedure variables.

kupferstecher

  • Full Member
  • ***
  • Posts: 218
Re: [Feature Request] Verbosity...
« Reply #12 on: July 01, 2018, 03:55:55 pm »
OK, thanks!

ASBzone

  • Jr. Member
  • **
  • Posts: 78
  • Automation leads to relaxation...
    • BrainWaveCC Utilities
Re: [Feature Request] Verbosity...
« Reply #13 on: July 01, 2018, 05:10:08 pm »
Since you're not a developer of Lazarus, my guess is the request wasn't directed at you, and again, not your place to chime in.

You asked a question on a publicly accessible forum.  It's anyone's place to chime in that is a member of that forum.

No one has stopped you from asking for new features.  It is just ironic that you would wax eloquent about the individual virtues of various programming languages, and then without getting even moderately up to speed on FreePascal, you see to change it to something more familiar.  No-one has deprived you of your freedom to make feature requests, and you can likewise deny no one their freedom to comment on said requests.

And, in fact, I offered you a suggested solution to your request -- one which you could implement today.

Thaddy's response is admittedly cooler, and supported by the compiler, too.
-ASB: https://www.BrainWaveCC.com

Lazarus 1.8.4 + FPC 3.0.4 (32-bit w/64-bit cross-compile)
Occasional testing of NewPascal
Windows 10 Pro x64, Version 1803 (Build 17134.228)

(Technically, I logon to these forums from multiple versions of Windows Pro/Enterprise...)

GypsyPrince

  • New member
  • *
  • Posts: 34
Re: [Feature Request] Verbosity...
« Reply #14 on: July 01, 2018, 05:36:00 pm »
marcov ~

That is a lot of useful info, as well as a thorough explanation of why my request should not be implemented.
« Last Edit: July 02, 2018, 02:31:08 am by GypsyPrince »
May the mass * acceleration be with you!

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus