Re: [fpc-devel] Minor debate with ISO standard on case blocks

2019-07-31 Thread Marco Borsari via fpc-devel
Il 31/07/2019 08:37, thaddy ha scritto: On 2019-07-31 08:26, Marco Borsari via fpc-devel wrote: What needs to be detected if all *used* labels are within the confines of the used ordinal, but a selector without label should throw an error. In the case of my patch it behaves like extended pasc

Re: [fpc-devel] Minor debate with ISO standard on case blocks

2019-07-31 Thread thaddy
On 2019-07-31 08:26, Marco Borsari via fpc-devel wrote: On Wed, 31 Jul 2019 01:26:23 +0200 Martok wrote: Of course, if you wanted a run-time error you would need to insert a run-time check, and 'some people' seemed to be hell-bent on saving these 2 cycles at any cost. The patch to switch fr

Re: [fpc-devel] Minor debate with ISO standard on case blocks

2019-07-31 Thread thaddy
I might add to my previous post that case(2) is open for discussion after the patch: One might argue that also in the case of ISO 10206 the compiler should throw a compile-time error in that particular case, because it is already obvious that the value has no label. Therefor I left out a correc

Re: [fpc-devel] Minor debate with ISO standard on case blocks

2019-07-31 Thread thaddy
Indeed the wording between 7185 and 10206 has changed little, but important: dynamic. Therefor note I still think the patch is acceptable. I studied some more on the subject and here I will try and explain what the actual behavior needs to be when one want to interpret the ISO 7185 case very st

Re: [fpc-devel] Minor debate with ISO standard on case blocks

2019-07-31 Thread thaddy
I have the faint suspicion that the case chapter in the extended pascal standard is a deliberate rephrasing of the one in iso 7185:1990. Specifically adding the wording "dynamic" with regard to the error type. ___ fpc-devel maillist - fpc-devel@lists.

Re: [fpc-devel] Minor debate with ISO standard on case blocks

2019-07-31 Thread thaddy
On 2019-07-30 14:04, Sven Barth via fpc-devel wrote: thaddy schrieb am Di., 30. Juli 2019, 10:04: On 2019-07-30 01:43, J. Gareth Moreton wrote: As someone on the issue pointed out... on page 2, section 3.1: 3.1 Error I have added this to the bug report. Consider that here all possible cas

Re: [fpc-devel] Minor debate with ISO standard on case blocks

2019-07-31 Thread thaddy
Scott Franco a.k.a. Moore says this, what makes sense, in his manual "Rules of ISO 7185": == Case statement The case statement defines an action to be executed on each of the values of an ordinal: case x of c1: statement; c2: statement; ... end; The "selector" i

Re: [fpc-devel] Minor debate with ISO standard on case blocks

2019-07-31 Thread thaddy
The C case block differs from Pascal's case block in that it falls through if no return is specified. That means a single value can trigger multiple case labels. In Pascal it can only trigger one case label. Because of the fall-through a default: has greater purpose than in Pascal.

Re: [fpc-devel] Minor debate with ISO standard on case blocks

2019-07-31 Thread thaddy
On 2019-07-30 12:26, Paul Breneman wrote: This message thread has been interesting to read. I just realized today that I dealt with similar issues in Delphi 19 years ago. This is discussed in the good Microsoft Press book *Code Complete* by Steve McConnell. Using the default else block of a ca

Re: [fpc-devel] Minor debate with ISO standard on case blocks

2019-07-31 Thread thaddy
On 2019-07-30 12:12, Marco Borsari via fpc-devel wrote: On Tue, 30 Jul 2019 06:38:56 +0200 thaddy wrote: According to what I found there is no smoking gun: I could not find any implementation or reference from any reputable source that implements the case statement in the way that is implemen

Re: [fpc-devel] Minor debate with ISO standard on case blocks

2019-07-31 Thread thaddy
On 2019-07-30 10:23, Michael Van Canneyt wrote: Just interpreting the standard, I think that the error should be run-time, not compile-time (although definitely keep the warning).  That's just my take on it though.  If it is to be changed, it should be simple enough by configuring the 'elselabe

Re: [fpc-devel] Minor debate with ISO standard on case blocks

2019-07-31 Thread thaddy
On 2019-07-30 11:18, J. Gareth Moreton wrote: Yeah, I don't find that description clear either.  One shouldn't have to be a lawyer in order to decrypt such standards! Of course, FPC can follow its own standard, but it should be one that everyone agrees on.  While I think we shouldn't live in the

Re: [fpc-devel] Minor debate with ISO standard on case blocks

2019-07-31 Thread thaddy
I submitted a patch so that iso mode behaves like extended pascal mode. i.e. The compile time error is gone (also in the case I showed to be a true bug) And a run-time error is issued as per extendedpascal. Solves most problems I have with the "feature" and existing code written in iso mo

Re: [fpc-devel] Minor debate with ISO standard on case blocks

2019-07-30 Thread Marco Borsari via fpc-devel
On Wed, 31 Jul 2019 01:26:23 +0200 Martok wrote: > Of course, if you wanted a run-time error you would need to insert a run-time > check, and 'some people' seemed to be hell-bent on saving these 2 cycles at > any > cost. > > The patch to switch from option a1) to a2) would be straightforward, f

Re: [fpc-devel] Minor debate with ISO standard on case blocks

2019-07-30 Thread Martok
If you want something a bit more clear, try ISO/IEC 10206 (Extended Pascal). They split up errors and dynamic violations, which helps make the point clearer. Basically, a "Processor" is sort of an interpreter that first validates the complete program and then activates the program block, "executio

Re: [fpc-devel] Minor debate with ISO standard on case blocks

2019-07-30 Thread Sven Barth via fpc-devel
thaddy schrieb am Di., 30. Juli 2019, 10:04: > On 2019-07-30 01:43, J. Gareth Moreton wrote: > > As someone on the issue pointed out... on page 2, section 3.1: > > > > 3.1 Error > > > I have added this to the bug report. Consider that here all possible > case labels are implemented, the compiler

Re: [fpc-devel] Minor debate with ISO standard on case blocks

2019-07-30 Thread Stefan Glienke
Actually I prefer a compiler error/warning on such cases - so being able to write an exhaustive case is a very good option over eventually getting runtime errors - oh, yeah we all have exhaustive unit tests don't we? ;) TypeScript for example has the never type which can be used to write a comp

Re: [fpc-devel] Minor debate with ISO standard on case blocks

2019-07-30 Thread Paul Breneman
This message thread has been interesting to read. I just realized today that I dealt with similar issues in Delphi 19 years ago. This is discussed in the good Microsoft Press book *Code Complete* by Steve McConnell. Using the default else block of a case statement to show a program error mes

Re: [fpc-devel] Minor debate with ISO standard on case blocks

2019-07-30 Thread Marco Borsari via fpc-devel
On Tue, 30 Jul 2019 06:38:56 +0200 thaddy wrote: > According to what I found there is no smoking gun: I could not find any > implementation or reference from any reputable source that implements > the case statement in the way that is implemented in trunk: compile time > error when not all of

Re: [fpc-devel] Minor debate with ISO standard on case blocks

2019-07-30 Thread Michael Van Canneyt
On Tue, 30 Jul 2019, Martin Frb wrote: How you're suppsed to construct a working & compliant 'processor' (I assume this means compiler or interpreter or somesuch) after reading this is a mystery to me. Well if we make the following substitutions (to specialize the statement for the case of

Re: [fpc-devel] Minor debate with ISO standard on case blocks

2019-07-30 Thread Martin Frb
On 30/07/2019 10:29, Michael Van Canneyt wrote: On Tue, 30 Jul 2019, thaddy wrote: Telling. NOTES 1. If it is possible to construct a program in which the violation or non-violation of this International Standard requires knowledge of the data read by the program or the implementation defi

Re: [fpc-devel] Minor debate with ISO standard on case blocks

2019-07-30 Thread J. Gareth Moreton
Yeah, I don't find that description clear either.  One shouldn't have to be a lawyer in order to decrypt such standards! Of course, FPC can follow its own standard, but it should be one that everyone agrees on.  While I think we shouldn't live in the shadow of Delphi or be jammed in the realm

Re: [fpc-devel] Minor debate with ISO standard on case blocks

2019-07-30 Thread Michael Van Canneyt
On Tue, 30 Jul 2019, thaddy wrote: Telling. NOTES 1. If it is possible to construct a program in which the violation or non-violation of this International Standard requires knowledge of the data read by the program or the implementation definition of implementation-defined features, then v

Re: [fpc-devel] Minor debate with ISO standard on case blocks

2019-07-30 Thread Michael Van Canneyt
On Mon, 29 Jul 2019, J. Gareth Moreton wrote: Hi everyone, So there's been an issue raised in regards to ISO compliance with case blocks (when under $mode iso).  Currently, a compiler error is raised if a case block does not have exhaustive c

Re: [fpc-devel] Minor debate with ISO standard on case blocks

2019-07-30 Thread thaddy
On 2019-07-30 01:43, J. Gareth Moreton wrote: As someone on the issue pointed out... on page 2, section 3.1: 3.1 Error I have added this to the bug report. Consider that here all possible case labels are implemented, the compiler still throws a compile time error. That means the implementa

Re: [fpc-devel] Minor debate with ISO standard on case blocks

2019-07-30 Thread thaddy
Telling. I took the trouble to look up the case statement in a random selection of about 30 instruction manuals, books and magazines about Pascal from my personal library (only a few pretend to be ISO compliant or mention the standard, though. These beasts are rare) and some compilers. I can n

Re: [fpc-devel] Minor debate with ISO standard on case blocks

2019-07-29 Thread J. Gareth Moreton
As someone on the issue pointed out... on page 2, section 3.1: 3.1 Error A violation by a program of the requirements of this International Standard that a processor is permitted to leave undetected. NOTES 1. If it is possible to construct a program in which the violation or non-violation o

[fpc-devel] Minor debate with ISO standard on case blocks

2019-07-29 Thread J. Gareth Moreton
Hi everyone, So there's been an issue raised in regards to ISO compliance with case blocks (when under $mode iso).  Currently, a compiler error is raised if a case block does not have exhaustive coverage for the input type (it's a warning on oth