Re: [fpc-pascal] implementation-part

2023-12-14 Thread Michael Van Canneyt via fpc-pascal




On Fri, 15 Dec 2023, Adriaan van Os via fpc-pascal wrote:



The Freepascal Language Reference (version 3.2.0) states in section 16.2

"As can be seen from the syntax diagram, a unit always consists of a 
interface and an implementation part."


and

"Both the interface part or implementation part can be empty, but the 
keywords Interface and implementation must be specified.


However, this was changed when implementing macpas mode (or at least for the 
macpas mode) in that the implementation part is no longer obligatory. This is 
useful for units with (only) external declarations.


Really ?

Not being a macpas user, I was not aware of this. 
I will update the documentation.


Thank you for pointing it out.

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] implementation-part

2023-12-14 Thread Adriaan van Os via fpc-pascal



The Freepascal Language Reference (version 3.2.0) states in section 16.2

"As can be seen from the syntax diagram, a unit always consists of a interface and an 
implementation part."


and

"Both the interface part or implementation part can be empty, but the keywords Interface and 
implementation must be specified.


However, this was changed when implementing macpas mode (or at least for the macpas mode) in that 
the implementation part is no longer obligatory. This is useful for units with (only) external 
declarations.


Regards,

Adriaan van Os
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] case statement

2023-12-14 Thread James Richters via fpc-pascal
I have occasionally had ambiguity with ELSE, for example when you have IF
statements nested inside other IF statements, 
sometimes the ELSE is seen as part of the inner, not the outer, or vice
versa, depending on where the one-liners are
but I just resolve it with some BEGIN - END Blocks, even if they are not
actually needed because there is only one line,  ambiguity resolved. 

For years I have just been in the habit of always putting BEGIN and END on
all IF and ELSE statements, as well as all entries of
CASE statements, whether needed or not,  just because it's so much easier to
stick in some temporary diagnostic code if needed,
it's easier to just always have them and not have to add them later if you
want to do a second thing, which always seems to be happening. 
I guess that's why I never noticed there could be an issue with CASE
statements.

It is handy to know about OTHERWISE though, I'll probably throw it in just
to help remind me that this belongs to the CASE
Statement, and not part of some IF, maybe it will be more readable that way.

James


-Original Message-
From: fpc-pascal  On Behalf Of
Martin Wynne via fpc-pascal
Sent: Thursday, December 14, 2023 3:16 PM
To: fpc-pascal@lists.freepascal.org
Cc: Martin Wynne 
Subject: Re: [fpc-pascal] case statement

I've been using ELSE in IF statements and in CASE statements for 25 years
without realising there was a problem. What a dim-wit I have been.

Martin.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] case statement

2023-12-14 Thread Martin Wynne via fpc-pascal
I've been using ELSE in IF statements and in CASE statements for 25 
years without realising there was a problem. What a dim-wit I have been.


Martin.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] case statement

2023-12-14 Thread Adriaan van Os via fpc-pascal

James Richters via fpc-pascal wrote:

I didn’t know there was such a thing as OTHERWISE.  Is there any functional 
difference between OTHERWISE and ELSE?


No. It is just that OTHERWISE doesn't have the IF-THEN-ELSE ambiguity. Macintosh Pascal compilers 
had OTHERWISE but not ELSE. Maybe, OTHERWISE was added to FPC when imlementing the macpas mode.


Regards,

Adriaan van Os
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] case statement

2023-12-14 Thread Sven Barth via fpc-pascal
James Richters via fpc-pascal  schrieb am
Do., 14. Dez. 2023, 20:13:

> I didn’t know there was such a thing as OTHERWISE.  Is there any
> functional difference between OTHERWISE and ELSE?
>

"otherwise" is what had been defined by ISO Extended Pascal for the
cause-statement.

Aside from not having the else-problem mentioned in this thread there is no
functional difference.

Regards,
Sven

>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] case statement

2023-12-14 Thread James Richters via fpc-pascal
I didn’t know there was such a thing as OTHERWISE.  Is there any functional 
difference between OTHERWISE and ELSE?

James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] case statement

2023-12-14 Thread Adriaan van Os via fpc-pascal

Michael Van Canneyt via fpc-pascal wrote:



On Thu, 14 Dec 2023, Adriaan van Os via fpc-pascal wrote:



I am looking in detail at the syntax diagrams in the Freepascal 
Language Reference (version 3.2.0)


Section 13.2.2 discusses the case-statement. Translated to EBNF (WSN) 
the syntax is


case-statement = "CASE" expression "OF" case { ";" case } [ else-part 
] [ ";" ] .
case = constant [ ".." constant ] { "," constant [ ".." constant ] } 
":" statement .

else-part = [ "ELSE" | "OTHERWISE" ] statementlist .

If this is correct (and the compiler really allows it) then a 
semicolon between  and  is not required.


It is not required.


In addition to what I wrote, I believe the  diagram is also incorrect in that it 
doesn't allow an optional semicolon between  and .


Regards,

Adriaan van Os
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] case statement

2023-12-14 Thread Michael Van Canneyt via fpc-pascal




On Thu, 14 Dec 2023, Adriaan van Os via fpc-pascal wrote:



I am looking in detail at the syntax diagrams in the Freepascal Language 
Reference (version 3.2.0)


Section 13.2.2 discusses the case-statement. Translated to EBNF (WSN) the 
syntax is


case-statement = "CASE" expression "OF" case { ";" case } [ else-part ] [ ";" 
] .
case = constant [ ".." constant ] { "," constant [ ".." constant ] } ":" 
statement .

else-part = [ "ELSE" | "OTHERWISE" ] statementlist .

If this is correct (and the compiler really allows it) then a semicolon 
between  and  is not required.


It is not required.

Consequently, there is an 
ambiguity between an if-then-else statement (as last statement of the ) 
and an if-then statement (as last statement of the ) and an 
. This is extremely dangerous and I feel that at least the 
Language Reference should warn against it.


A good point. I will add a warning.



Even with an obliged semicolon, I always use "OTHERWISE instead of ELSE, but 
that's my personal preference.


Indeed. By contrast I abhorr the OTHERWISE. Tastes differ.

Thanks for bringing the ambiguity to my attention.

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] case statement

2023-12-14 Thread Bart via fpc-pascal
On Thu, Dec 14, 2023 at 5:01 PM Adriaan van Os via fpc-pascal
 wrote:

> I always use "OTHERWISE instead of ELSE, but that's my personal
> preference.

+1
Seeing  OTHERWISE in source code just makes me smile.

-- 
Bart
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] case statement

2023-12-14 Thread Adriaan van Os via fpc-pascal



I am looking in detail at the syntax diagrams in the Freepascal Language 
Reference (version 3.2.0)

Section 13.2.2 discusses the case-statement. Translated to EBNF (WSN) the 
syntax is

case-statement = "CASE" expression "OF" case { ";" case } [ else-part ] [ ";" ] 
.
case = constant [ ".." constant ] { "," constant [ ".." constant ] } ":" 
statement .
else-part = [ "ELSE" | "OTHERWISE" ] statementlist .

If this is correct (and the compiler really allows it) then a semicolon between  and 
 is not required. Consequently, there is an ambiguity between an if-then-else statement 
(as last statement of the ) and an if-then statement (as last statement of the ) and an 
. This is extremely dangerous and I feel that at least the Language Reference should 
warn against it.


Even with an obliged semicolon, I always use "OTHERWISE instead of ELSE, but that's my personal 
preference.


By the way, the Language Reference doesn't specify what a  is.

Regards,

Adriaan van Os

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal