Recent

Author Topic: Hello and how useful and worthwhile is Free Pascal?  (Read 35141 times)

munair

  • Hero Member
  • *****
  • Posts: 798
  • compiler developer @SharpBASIC
    • SharpBASIC
Re: Hello and how useful and worthwhile is Free Pascal?
« Reply #135 on: April 11, 2019, 10:47:49 am »
I am grateful for 440bx's suggestion. I just implemented the scope block. Although the scope block itself was already on my feature list, the exit ability was not. This now runs fine:

Code: Text  [Select][+][-]
  1. var a: 0;
  2.  
  3. scope do
  4.   var a: 1;
  5.   if a == 1 do
  6.     print("scoped a: " + string(a));
  7.     exit;
  8.   end;
  9.   print("end scope");
  10. end;
  11.  
  12. print("global a: " + string(a));

Output:
scoped a: 1
global a: 0
keep it simple

440bx

  • Hero Member
  • *****
  • Posts: 4037
Re: Hello and how useful and worthwhile is Free Pascal?
« Reply #136 on: April 11, 2019, 12:49:25 pm »
especially if they're only syntactic sugar on steroids or some alias for an existing feature (like your inout suggestion (see below)).
I am out (pun intended) of ways to explain that inout isn't syntactic sugar.  You guys are mixing two things that are independent of each other.  One is to let the compiler know if something should be passed by value or by reference and the other is to let the compiler know how that variable will be used, is it read-only, is it write-only or read-write ? (obviously applicable only to variables passed by reference)... if the compiler had that information then it can do better error checking.  Instead, you guys have associated var with initialized variables because, since it is a common mistake, you wanted to warn the programmer when the variable isn't initialized. The result: piles of worthless compiler messages and incorrectly redefining the semantics of var.   Niklaus Wirth made the purpose and semantic scope of "var" quite clear in its Pascal report but, even that doesn't seem to get across.

I am not going to explain it again.  As Einstein said, insanity is to do keep doing the same thing and expecting a different result. 

They allow for code like this:
Code: Pascal  [Select][+][-]
  1. var
  2.   p: PLongInt;
  3. begin
  4.   p := GetAPLongIntFromSomeWhere;
  5.   while p^ <> 0 do begin
  6.     DoSomethingWithP(p^);
  7.     Inc(p);
  8.   end;
  9. end.
Maybe I'm missing your point but, I don't see anything in that code that can't be accomplished using standard Pascal constructs.  That said, I do find the feature convenient (C/C++ pollution).  The reason I brought it up is because when someone uses (and misuses) the argument "it's already there" (even when it isn't, as you do with inout) then it is one of the constructs that serves to show how hollow that argument is.

The problem is reality: var is used in the way that users read the passed in value (aside from legacy code which used var because out didn't exist yet) and there have been enough users bitten by not-initialized variables passed to var parameters that it was more useful to add a warning so that they wouldn't fall into that trap.
The reality is that, in an effort to help users avoid a common mistake, you guy made another one.  You created an association that neither exists nor should be there.  And in sort-of solving one problem (uninitialized variables) you created another one: piles of useless messages that get in the way and bury genuinely useful messages that are now difficult to spot because of all the unnecessary junk the compiler is outputting.     I give you credit for good intentions but, it paved a path to message overload hell.  That alone should make you guys reconsider that decision.

Microsoft opened up the PDB format when they worked on clang so that they can use it as a frontend for their code generator backend (see here).
I had seen that and, to use that to state that MS opened up the PDB format is, IMO, a bit of an overstatement.  As it says there, that thing doesn't compile and if someone wants to have their compiler output MS debug symbols in a PDB, even with that, they have a good (and not easy) way to go. 

Another thing that I find interesting, apparently the LLVM guys put in the additional work needed to fully reverse engineer the PDB format but, one thing that seems missing is, usable documentation from _them_ showing how to use the PDB format.

MS paid lip service to "opening the PDB" format.  They threw a bone (better than nothing) and the dog that got the bone seems to have quietly kept it for itself.

It would literally be great if the VS debugger could be used - with full symbolic information - to debug FPC executables.  Now, I'm really dreaming, if it could limit the output to the subset used in old PDBs then, FPC 32bit executables could be debugged with Softice.  Only St. Peter has something better to offer than that.

Now, if St. PascalDragon would get rid of the incorrect association of var with initialized variables, that would be pretty good, it would definitely pave the way to eventually meeting St. Peter with a smile.

I am grateful for 440bx's suggestion. I just implemented the scope block. Although the scope block itself was already on my feature list, the exit ability was not.
I'm pleased to see control-flow features implemented in a language.  They really help simplify algorithms.  As far as the question you had about which scope break acts on, it's always the scope that contains it.   Just like break in any loop, the difference is, the scope doesn't loop over anything, it just delimits a group of statements.  The part to be careful about is carefully defining which statements create a scope, if that isn't precisely defined then it can result in ambiguities.


(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Kays

  • Hero Member
  • *****
  • Posts: 575
  • Whasup!?
    • KaiBurghardt.de
Re: Hello and how useful and worthwhile is Free Pascal?
« Reply #137 on: April 11, 2019, 02:47:07 pm »
[…] Syntactically, C is a language that looks like the product of an epileptic chicken having a seizure on a bad day and, that is on a good day.  […]
:D
[…] Or does everyone mostly only use the Lazarus IDE and not the text mode IDE?
I don't. I don't use any IDE. (I use butterflies.)
I always use 2, but it really is a programmer's preference. Many programmers use 3, some even 4.
No, not 4. It has to be prime, so 5, 7, 11 and so on are valid indentation depths.  ;)
Yours Sincerely
Kai Burghardt

munair

  • Hero Member
  • *****
  • Posts: 798
  • compiler developer @SharpBASIC
    • SharpBASIC
Re: Hello and how useful and worthwhile is Free Pascal?
« Reply #138 on: April 11, 2019, 02:53:49 pm »
I always use 2, but it really is a programmer's preference. Many programmers use 3, some even 4.
No, not 4. It has to be prime, so 5, 7, 11 and so on are valid indentation depths.  ;)
Yeah, my computer explodes without a prime indent.  8-)
keep it simple

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Hello and how useful and worthwhile is Free Pascal?
« Reply #139 on: April 11, 2019, 03:05:24 pm »
No, not 4. It has to be prime, so 5, 7, 11 and so on are valid indentation depths.  ;)

Yeah, but note that the series starts with: (2, 3, 5, 7, ...) so 2 (the conventional) or 3 are good also.:D


* In case it's not clear for beginners, all this is meant as a joke.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Hello and how useful and worthwhile is Free Pascal?
« Reply #140 on: April 12, 2019, 02:18:30 am »
As 66 is not prime, I was contemplating an indent of 101, because it is a fine US Route from Washington state to southern California that I have ridden on motorcycle. Unfortunately that proved impractical, so I use 2. US Route 2 runs from Wisconsin to Washington state, which I have also ridden, so that works for me.

« Last Edit: April 12, 2019, 02:30:01 am by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Hello and how useful and worthwhile is Free Pascal?
« Reply #141 on: April 12, 2019, 07:49:41 am »
As 66 is not prime, I was contemplating an indent of 101, because it is a fine US Route from Washington state to southern California that I have ridden on motorcycle. Unfortunately that proved impractical, so I use 2. US Route 2 runs from Wisconsin to Washington state, which I have also ridden, so that works for me.

You should reconsider 101 as a binary number: 5, which is also prime and practical.

munair

  • Hero Member
  • *****
  • Posts: 798
  • compiler developer @SharpBASIC
    • SharpBASIC
Re: Hello and how useful and worthwhile is Free Pascal?
« Reply #142 on: April 12, 2019, 08:08:24 am »
One is to let the compiler know if something should be passed by value or by reference and the other is to let the compiler know how that variable will be used, is it read-only, is it write-only or read-write ?

Things should be kept simple. The default should be by value and a (simple) keyword should be used to indicate by reference. My preference would be a keyword like byref which is unmistakable. IMO  there's no need for const parameters if the default is by value. A const byref parameter wouldn't make sense anyway.
keep it simple

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: Hello and how useful and worthwhile is Free Pascal?
« Reply #143 on: April 12, 2019, 09:14:31 am »
As 66 is not prime, I was contemplating an indent of 101, because it is a fine US Route from Washington state to southern California that I have ridden on motorcycle. Unfortunately that proved impractical, so I use 2. US Route 2 runs from Wisconsin to Washington state, which I have also ridden, so that works for me.
The problem with that is that if indentation is prime it would run longitudinal, not latitudinal.... :o :P  Which makes it clash with linebreaks.
« Last Edit: April 12, 2019, 09:20:46 am by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

whm1974

  • New Member
  • *
  • Posts: 24
Re: Hello and how useful and worthwhile is Free Pascal?
« Reply #144 on: April 12, 2019, 09:48:25 am »
Just found out about this magazine for Object Pascal users:
https://www.blaisepascalmagazine.eu/

How useful would a subscription be to me at this stage? Anyone reads this?

PascalDragon

  • Hero Member
  • *****
  • Posts: 5481
  • Compiler Developer
Re: Hello and how useful and worthwhile is Free Pascal?
« Reply #145 on: April 12, 2019, 09:49:13 am »
Now, if St. PascalDragon would get rid of the incorrect association of var with initialized variables, that would be pretty good, it would definitely pave the way to eventually meeting St. Peter with a smile.
Not happening.

440bx

  • Hero Member
  • *****
  • Posts: 4037
Re: Hello and how useful and worthwhile is Free Pascal?
« Reply #146 on: April 12, 2019, 02:11:58 pm »
Things should be kept simple. The default should be by value and a (simple) keyword should be used to indicate by reference. My preference would be a keyword like byref which is unmistakable. IMO  there's no need for const parameters if the default is by value. A const byref parameter wouldn't make sense anyway.
I completely agree they should be kept simple and, things that are separate should be kept separate.   Informing the compiler whether a variable is passed by value or by reference has nothing to do with telling the compiler how the variable is used.   Two completely different things independent of each other.  Problems occur when the two get mixed.  In your language, I suggest to keep them separate which is how they should be.


Now, if St. PascalDragon would get rid of the incorrect association of var with initialized variables, that would be pretty good, it would definitely pave the way to eventually meeting St. Peter with a smile.
Not happening.
That's what I thought but, since miracles do occasionally happen, I thought I'd give common sense a chance.  I'll try not to be so optimistic in the future.

(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: Hello and how useful and worthwhile is Free Pascal?
« Reply #147 on: April 12, 2019, 02:19:08 pm »
Just found out about this magazine for Object Pascal users:
https://www.blaisepascalmagazine.eu/

How useful would a subscription be to me at this stage? Anyone reads this?
It is the only decent magazine about ObjectPascal, but lacks a bit of stuff for real beginners. But it is not too expensive. Download a free issue and see for yourself if it fits your capabilities.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11453
  • FPC developer.
Re: Hello and how useful and worthwhile is Free Pascal?
« Reply #148 on: April 12, 2019, 02:32:34 pm »
Things should be kept simple. The default should be by value and a (simple) keyword should be used to indicate by reference. My preference would be a keyword like byref which is unmistakable. IMO  there's no need for const parameters if the default is by value. A const byref parameter wouldn't make sense anyway.
I completely agree they should be kept simple and, things that are separate should be kept separate.   Informing the compiler whether a variable is passed by value or by reference has nothing to do with telling the compiler how the variable is used.   Two completely different things independent of each other.  Problems occur when the two get mixed.  In your language, I suggest to keep them separate which is how they should be.

The ABI rules what is passed by values depending sizes that can be in register, and internal buildup varies per architecture. It is wise to match that, otherwise you get into trouble with header translation.  CONST signals that it shouldn't be modified even if not passed by reference.


440bx

  • Hero Member
  • *****
  • Posts: 4037
Re: Hello and how useful and worthwhile is Free Pascal?
« Reply #149 on: April 12, 2019, 02:40:20 pm »
The ABI rules what is passed by values depending sizes that can be in register, and internal buildup varies per architecture. It is wise to match that, otherwise you get into trouble with header translation.  CONST signals that it shouldn't be modified even if not passed by reference.
I have no argument with that.  That doesn't prevent having a compiler declare how the parameter is used in addition to whether it is passed by value or reference.  That's the reason, "in" "inout", etc are being "synthesized" in C/C++.  And one doesn't get a torrent of useless, non-applicable compiler messages as a result of it (because they did it correctly.)


(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

 

TinyPortal © 2005-2018