issue-#125 Compiler TRAP for WITH statement

cfbsoftware
Posts: 204
Joined: Wed Sep 18, 2013 10:06 pm
Contact:

Re: issue-#125 Compiler TRAP for WITH statement

Post by cfbsoftware »

WithStatement = WITH [ Guard DO StatementSequence ]
{"|" [ Guard DO StatementSequence ] }
[ELSE StatementSequence] END.
Guard = Qualident ":" Qualident.
It is interesting to compare this with the original Oberon-2 version which would not allow the questionable construct under discussion:
WithStatement = WITH Guard DO StatementSequence
{"|" Guard DO StatementSequence}
[ELSE StatementSequence] END.
Guard = Qualident ":" Qualident.
I wonder why it was changed for CP?
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#125 Compiler TRAP for WITH statement

Post by Josef Templ »

My guess: It was changed in order to allow more freedom in formatting (also the first guarded block can start with a "|"
very much like in a CASE) and it allows more freedom when commenting out a part of the guarded blocks, e.g. while testing.

I don't want to create the impression that this is very important for me.
But since it was allowed by the language definition for a long time
there is no reason to change that and the fix was very simple.

- Josef
User avatar
Robert
Posts: 1024
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: issue-#125 Compiler TRAP for WITH statement

Post by Robert »

Josef Templ wrote:I don't want to create the impression that this is very important for me.
Bugs should be fixed! ('Features' maybe not.)

This thread is about correct code. I have a hypothetical question: If the compiler TRAPed on incorrect code - maybe "WITH $ END" - rather than displaying some error message, would that be regarded as a bug?

(I am not suggesting the compiler does TRAP on this example - the question is hypothetical.)
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#125 Compiler TRAP for WITH statement

Post by Josef Templ »

Yes, this would be a bug in the compiler.
The compiler is supposed to produce error messages for all incorrect code.
Trapping is better than producing wrong code, i.e. ignoring existing errors, but
it is not a correct behavior of the compiler.

- Josef
Post Reply