Recent

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

VTwin

  • Hero Member
  • *****
  • Posts: 613
  • Former Turbo Pascal 3 user
Re: Hello and how useful and worthwhile is Free Pascal?
« Reply #150 on: April 12, 2019, 02:50:20 pm »
You should reconsider 101 as a binary number: 5, which is also prime and practical.

I overlooked that. Changing my settings now! :D

The problem with that is that if indentation is prime it would run longitudinal, not latitudinal.... :o :P  Which makes it clash with linebreaks.

Excellent point!  I underestimated the complexities involved in choosing a proper indentation. :o
« Last Edit: April 12, 2019, 02:56:59 pm by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

macOS 10.11.6: Lazarus 2.0.1 svn r60918 (64 bit Cocoa)
Ubuntu 18.04.2: Lazarus 2.0.0 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.0.0 (64 bit on VBox)

VTwin

  • Hero Member
  • *****
  • Posts: 613
  • Former Turbo Pascal 3 user
Re: Hello and how useful and worthwhile is Free Pascal?
« Reply #151 on: April 12, 2019, 03:06:20 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.

I use normally use const when passing a dynamic array as a parameter if I want to insure that nothing changes. I find it is helpful self documentation as well.
“Talk is cheap. Show me the code.” -Linus Torvalds

macOS 10.11.6: Lazarus 2.0.1 svn r60918 (64 bit Cocoa)
Ubuntu 18.04.2: Lazarus 2.0.0 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.0.0 (64 bit on VBox)

440bx

  • Hero Member
  • *****
  • Posts: 721
Re: Hello and how useful and worthwhile is Free Pascal?
« Reply #152 on: April 12, 2019, 03:14:50 pm »
I use normally use const when passing a dynamic array as a parameter if I want to insure that nothing changes. I find it is helpful self documentation as well.
That's what it is for.  For that, in FPC, I use constref because there is some "warning" in the FPC documentation that states that "const" doesn't necessarily mean the parameter will be passed by reference.

using FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6918
Re: Hello and how useful and worthwhile is Free Pascal?
« Reply #153 on: April 12, 2019, 03:24:58 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.

Correct, though with the annotation that doesn't need to be syntax. It can be pragma or attribute too. There are many languages that require directives if you deviate from the default calling conventions

Quote
That's the reason, "in" "inout", etc are being "synthesized" in C/C++.

I don't know those in C. What C standard were "in" and "inout" added? Same for C++.

I know that Microsoft has used them for a long while for the headers they generate from IDL/COM, but back then they were nonstandard. Did they get standarized since?

Quote
And one doesn't get a torrent of useless, non-applicable compiler messages as a result of it (because they did it correctly.)

The issues with those messages are an compound problems of immature message generation in the compiler and the origin of the headers, and some of that being for Delphi compatibility that has origins in win9x times. Maybe in addition also default warnings settings (a bit to high perhaps?).

Trying to invent new syntax to micromanage this won't fix either.
« Last Edit: April 15, 2019, 01:06:13 pm by marcov »

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6918
Re: Hello and how useful and worthwhile is Free Pascal?
« Reply #154 on: April 12, 2019, 03:31:58 pm »
That's what it is for.  For that, in FPC, I use constref because there is some "warning" in the FPC documentation that states that "const" doesn't necessarily mean the parameter will be passed by reference.

In old 32-bit x86 calling conventions const=constref. In newer (the ones introduced by intel with Pentium PRO, which e.g. Mac OS X follows), and e.g. newer Visual Studio's this is no longer the case. You need both if you want to write headers for both assumptions. Or at least a directive/pragma (and I favoured a directive when the pragma was added instead of change Tinterfacedobject to constref, that way Delphi mode could have triggered that pragma)

Classic winapi avoids the whole issue by mostly working with pointers.

440bx

  • Hero Member
  • *****
  • Posts: 721
Re: Hello and how useful and worthwhile is Free Pascal?
« Reply #155 on: April 12, 2019, 03:44:31 pm »
Correct, though with the annotation that doesn't need to be syntax. It can be pragma too. There are many languages that require directives if you deviate from the default calling conventions
Pragmas are meant for things that are not very common, like declaring a custom section in a PE file, not for common things.  They would litter the code.

I don't know those in C. What C standard were "in" and "inout" added? Same for C++.
I don't keep up to date with the C/C++ standard, therefore, I don't know if "in", "inout", etc are part of the standard but, I do know that they are rather informative when reading a header.  Of course, in typical C fashion, at least at this time, they may be just ornaments but, in the standard or not the point remains valid, they are useful.

I know that Microsoft has used them for a long while for the headers they generate from IDL/COM, but back then they were nonstandard.
They didn't "come up" with them to create busy-work for themselves.   The one thing C/C++ has over Pascal is that, slowly and steadily, capabilities that should be present in a programming language get added (even if it takes years but, they eventually get added.... C++ is a good example.)

The issues with those messages are an compound problems of immature message generation in the compiler and the origin of the headers, and some of that being for Delphi compatibility that has origins in win9x times. Maybe in addition also default warnings settings (a bit to high perhaps?).
That neither explains nor justifies not doing something about that obvious problem.  Much less explain or provide a foundation for the _refusal_ to fix it.

Trying to invent new syntax to micromanage this won't fix either.
Well, in that case declaring ranges, enumerated types and just about anything else that declares bounds for the compiler to use is, as you put it, "micromanaging". 

Giving information to the compiler isn't "micromanaging", it is part of what programming is all about.  Give information to the compiler so the compiler can use that information to let the programmer know of a possible problem between what he/she declared and the usage of the item declared.

added

Classic winapi avoids the whole issue by mostly working with pointers.
inout combined with out would be a clean way of solving a good portion of that problem.   I know, not going to happen, makes too much sense and it is probably too easy.


« Last Edit: April 12, 2019, 03:51:17 pm by 440bx »
using FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6918
Re: Hello and how useful and worthwhile is Free Pascal?
« Reply #156 on: April 12, 2019, 04:01:53 pm »
a.s. this is my last message on the topic. You don't seem to really think about contra arguments, and until that changes, I'm not going to bother anymore

Correct, though with the annotation that doesn't need to be syntax. It can be pragma too. There are many languages that require directives if you deviate from the default calling conventions
Pragmas are meant for this that are not very common, like declaring a custom section in a PE file, not for common things. 

Forcedly by ref against ABI rules should be not very common

They would litter the code.

Then you are doing something wrong.

I don't know those in C. What C standard were "in" and "inout" added? Same for C++.
I don't keep up to date with the C/C++ standard, therefore, I don't know if "in", "inout", etc are part of the standard but,
[/quote]

So all this glorifying of C/C++ was based on not even standard features? Typical.

Quote
I do know that they are rather informative when reading a header. 

So is reading about the history of the author, but I'm not pulling that in language either.

Quote
Of course, in typical C fashion, at least at this time, they may be just ornaments but, in the standard or not the point remains valid, they are useful.

They didn't "come up" with them to create busy-work for themselves.   

To my best knowledge they are mainly meant for interfacing  with higher level (COM, .NET, WinRT etc) components and codegenerators. Breathing users could look in the docs.

Not that it is a bad thing, but the exact form and rules for that vary with application. There is no real rule for it.

Quote
The one thing C/C++ has over Pascal is that, slowly and steadily, capabilities that should be present in a programming language get added (even if it takes years but, they eventually get added.... C++ is a good example.)

Yeah, you keep mentioning that, but don't know if the example that you name is actually standarized.

I slowly can't shake the feeling that you are just using C++ put on an artificial (and false) gold platform to stick it to FPC.

At the same time you take random FPC "problems", and without fully understanding and diving into them, blame not having the magical extensions for that.

Quote
That neither explains nor justifies not doing something about that obvious problem.  Much less explain or provide a foundation for the _refusal_ to fix it.

That is because the "problem" is subjective. You can simply turn off the warnings if they are useless.

Quote
Trying to invent new syntax to micromanage this won't fix either.
Well, in that case declaring ranges, enumerated types and just about anything else that declares bounds for the compiler to use is, as you put it, "micromanaging". 

They are for compilation and execution, not hypothetical warning avoidance in headers that won't use them anyway.
« Last Edit: April 12, 2019, 04:06:45 pm by marcov »

440bx

  • Hero Member
  • *****
  • Posts: 721
Re: Hello and how useful and worthwhile is Free Pascal?
« Reply #157 on: April 12, 2019, 04:47:53 pm »
Forcedly by ref against ABI rules should be not very common
Like in, inout and out are not very common things to need.  You'd like var to be specified with a pragma too instead of a keyword ?

Then you are doing something wrong.
programming... that's what's wrong.  The compiler emitting a torrent of useless messages, that is obviously absolutely right.   Nothing wrong at all with that.

So all this glorifying of C/C++ was based on not even standard features? Typical.
What's typical is your going besides the point.  I don't care if it's standard or not, I care that it is useful.  I'd say that some of my posts in this thread show rather clearly that I don't glorify C nor C++ but, I do find some of their features very useful and, I am not the only one who finds them useful.

I know, why would anyone add features that have proved to be useful in other languages into Pascal ?... obviously, that doesn't make any sense. 

So is reading about the history of the author, but I'm not pulling that in language either.
You're an artist when it comes to go besides the point.  The author's history, unlike specifications like "in", "inout", etc, doesn't give any usable information to the compiler (I really thought that didn't need to be clarified.)

To my best knowledge they are mainly meant for interfacing  with higher level (COM, .NET, WinRT etc) components and codegenerators. Breathing users could look in the docs.
Start breathing!!  you'll find they might be useful in Pascal too (not to mention that breathing will prove extremely useful to you.... now I understand where your position comes from...lack of oxygen... that will do it.)

Yeah, you keep mentioning that, but don't know if the example that you name is actually standarized.
I don't care if it's standardized or not.  Strange for someone who follows a language definition which has not been standardized, that is Delphi, to implicitly require it.

However, I do care that the C and C++ standards evolve.  They don't stay stagnant. I also care that it is that way because their users are not obstinately reluctant to add useful features to the language and worse, stick their heads in the sand in the face of obvious problems (yes, useless compiler messages, again.)


I slowly can't shake the feeling that you are just using C++ put on an artificial (and false) gold platform to stick it to FPC.
I don't see where you get that idea.  I have no love for C and C++'s design, far from it.  In spite of that, I have to give them credit for what they have that is genuinely useful and, I openly admit that I'd like to see those useful features present in the Pascal language implemented the Pascal way, not the C/C++ way.

At the same time you take random FPC "problems", and without fully understanding and diving into them, blame not having the magical extensions for that.
Apparently, for you it isn't a problem to get a mound of useless messages that get in the way.  Believe it or not, it is a problem for other programmers.

There is nothing "magic" about in, inout, etc.  What seems to require "magic" is activating a smidgen of common sense in some of the FPC developers so they can notice and acknowledge an obvious problem.  Of course, getting them to acknowledge that the problem comes from a mistake they made, that may likely require something much beyond magic.  Obviously, logic need not apply.

That is because the "problem" is subjective. You can simply turn off the warnings if they are useless.
Yes, very subjective.  No doubt the reason the compiler is outputting those useless messages is because of the way I feel.  I hadn't thought about that.  Definitely subjective.  (is there a $SIGMUNDFREUD compiler directive that defaults to ON that I don't know about ?... that one really needs to be turned off.)

They are for compilation and execution, not hypothetical warning avoidance in headers that won't use them anyway.
The useless messages are not hypothetical, they are very real and, the reason the headers don't use them (e.g, out) is, among other reasons, because someone claimed it was too much work.  Otherwise they would.

using FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

metis

  • Full Member
  • ***
  • Posts: 147
Re: Hello and how useful and worthwhile is Free Pascal?
« Reply #158 on: April 15, 2019, 12:52:32 pm »
@whm1974

Quote
OK at this point you guys have done lost me...
Don't worry, You are not alone with this Feeling.
Maybe hyper-sophisticated Issues, that by experience (always) tend to turn to
Endless-Loops are worth Starting an own Topic to continue the Discussion there.

Quote
And how to get started.
http://forum.lazarus.freepascal.org/index.php/topic,43921.msg308212.html#msg308212,
especially
http://lazplanet.blogspot.com/p/beginners-guide.html
for an instant Sentiment of Success with FPC/Lazarus.  :)
Life could be so easy, if there weren't those f*** Details.

whm1974

  • New member
  • *
  • Posts: 24
Re: Hello and how useful and worthwhile is Free Pascal?
« Reply #159 on: April 17, 2019, 06:01:57 am »
@whm1974

Quote
OK at this point you guys have done lost me...
Don't worry, You are not alone with this Feeling.
Maybe hyper-sophisticated Issues, that by experience (always) tend to turn to
Endless-Loops are worth Starting an own Topic to continue the Discussion there.

Quote
And how to get started.
http://forum.lazarus.freepascal.org/index.php/topic,43921.msg308212.html#msg308212,
especially
http://lazplanet.blogspot.com/p/beginners-guide.html
for an instant Sentiment of Success with FPC/Lazarus.  :)
Thanks I should find this helpful. I guess I should start reading... ;D