Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2019-05

FPC Language Specification

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

J. Gareth Moreton

So after my argument and the counterarguments regarding the new case block warnings, I'm starting to wonder if a semi-official specification should be written for FPC's dialect of Pascal, much like ISO 7185 for Extended Pascal.  While FPC is probably the only tool that will use this dialect, it would be useful as a future reference guide as well as for conformance testing.

It might also aid in third-party documentation and enforcing coding standards so that all developers who use Free Pascal know what to expect from the language.  Case in point, I never knew that, strictly speaking, case blocks that didn't cover all possible inputs required an else branch even if it was empty - given the code compiled fine without it and its absence logically indicated that such a branch wasn't required, there was nothing to say that I was in conflict with some Pascal standards and getting an accusation of being a lazy programmer.  In this case, I fell back to a paradigm of being concise and straightforward, not adding unnecessary code such as, for example, constructors that do nothing but call the inherited version with no changes to the parameter list.

Back on topic though, as well as leaving no doubt as to how the language behaves, it might also work as a design specification to an extent.  For example, I still intend to program in support for pure functions, but beyond the *pure* directive (assuming all functions are pure until proven otherwise will cause too much of a performance penalty on the compiler) and the basic concept of their results being computed at compile time if possible, there isn't much else set in stone like where a pure function can be called (e.g. as part of a constant definition), what happens if the compiler determines that a pure function is actually impure, and what makes a function impure.  Having something like this fully decided and agreed upon in a language specification will ensure there are no disagreements with implementation specifics.

Long story short, having a specification with statements like "/Case blocks must have a valid branch for all possible input values, either through branches for individual values and ranges, or via an //*else*//branch.  Not abiding by this condition will raise a compiler warning./" and "/An "Unreachable code" warning shall be thrown if a case block contains an else branch but which already covers the entire input domain via other branches./" will go a long way to ensure the language stays conformant and tidy, I feel.

While there is documentation online that can easily explain all of this, I find it's only truly useful if you are looking up details on a specific feature - for example, the standard of expanding intermediate expressions to the CPU word size has caught many programmers off-guard.  Having it in a single specification means that the curious can read through it in its entirety to learn of these nuances before falling foul of them.

What are your thoughts?

Gareth aka. Kit

P.S. I'm aware that writing it will be a mammoth task, especially to make it semi-official in its wording.  I have done paid proofreading work before so I can ensure that what I write is acceptable English, but it would need many sets of eyes evaluating it.

---
This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

Reply by email

Michael Van Canneyt
to J. Gareth Moreton
J. Gareth Moreton wrote 9 lines
While there is documentation online that can easily explain all of this, I find it's only truly useful if you are looking up details on a specific feature - for example, the standard of expanding intermediate expressions to the CPU word size has caught many programmers off-guard.  Having it in a single specification means that the curious can read through it in its entirety to learn of these nuances before falling foul of them. What are your thoughts?

Maybe start from the official ISO pascal or extended pascal specs and rewrite that to match the compiler implementation.

Michael.

Reply by email

J. Gareth Moreton
to Michael Van Canneyt
Michael Van Canneyt wrote 19 lines
On Mon, 20 May 2019, J. Gareth Moreton wrote: > > While there is documentation online that can easily explain all of > this, I find it's only truly useful if you are looking up details on > a specific feature - for example, the standard of expanding > intermediate expressions to the CPU word size has caught many > programmers off-guard.  Having it in a single specification means > that the curious can read through it in its entirety to learn of > these nuances before falling foul of them. > > What are your thoughts? Maybe start from the official ISO pascal or extended pascal specs and rewrite that to match the compiler implementation. Michael.

Normally it doesn't quite work that way.  It's more about what we expect and desire the language to do from a design perspective - it is allowed to change with implementation considerations, but normally it's not the first point of consideration.  To give the example of case blocks, since that's been a point of contention lately, do we specify that all possible input values have a valid branch and enumerated inputs aren't range-checked, or do we just go by the implementation and say "it's not a bug, it's a feature" if something looks different?  There's also the point that we may desire the language to behave a certain way, but a subtle bug in the implementation means that it doesn't under certain circumstances?

I suppose going by the implementation is better than nothing, but normally it's not taken to be the definitive authoritive guide.

And for new features like *pure* functions, I much rather have something written down and locked before I blindly start programming them and making it up as I go along.

Gareth aka. Kit

---
This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

Reply by email

michael
to J. Gareth Moreton
J. Gareth Moreton wrote 34 lines
On 20/05/2019 09:44, Michael Van Canneyt wrote: > On Mon, 20 May 2019, J. Gareth Moreton wrote: > >> While there is documentation online that can easily explain all of >> this, I find it's only truly useful if you are looking up details >> on a specific feature - for example, the standard of expanding >> intermediate expressions to the CPU word size has caught many >> programmers off-guard. Having it in a single specification means >> that the curious can read through it in its entirety to learn of >> these nuances before falling foul of them. >> >> What are your thoughts? > > Maybe start from the official ISO pascal or extended pascal specs > and > rewrite that to match the compiler implementation. > > Michael. Normally it doesn't quite work that way. It's more about what we expect and desire the language to do from a design perspective - it is allowed to change with implementation considerations, but normally it's not the first point of consideration. To give the example of case blocks, since that's been a point of contention lately, do we specify that all possible input values have a valid branch and enumerated inputs aren't range-checked, or do we just go by the implementation and say "it's not a bug, it's a feature" if something looks different? There's also the point that we may desire the language to behave a certain way, but a subtle bug in the implementation means that it doesn't under certain circumstances? I suppose going by the implementation is better than nothing, but normally it's not taken to be the definitive authoritive guide.

Normally, you have a committee of people working on such things, and on top you have a backlog which will probably take the rest of your life to catch up with.

But hey, it's your time, don't let me stop you...

Michael.

Reply by email

J. Gareth Moreton
to michael

Normally, you have a committee of people working on such things,

Show quoted text 6 lines
and on top you have a backlog which will probably take the rest of your life to catch up with. But hey, it's your time, don't let me stop you... Michael.

Well, I'm going to be living those years anyway, and despite some occasional disagreements, I do enjoy developing for FPC!

Having a specification that the majority agrees upon would help in ensuring programmers don't fall foul of some of the nuances of the language, and having a committee for it stops absolute stinkers of features like the inlined var definitions in the most recent version of Delphi (yuck!).  Also, if I suddenly die from getting struck by a meteorite or something, at least most of the specifics of *pure* functions will be defined so someone can pick up where I left off if they feel up to it.

Gareth aka. Kit

P.S. I think your return e-mail got a little screwed up in the last message.

---
This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

Reply by email