Page 2 of 2
Re: issue-#125 Compiler TRAP for WITH statement
Posted: Fri Aug 26, 2016 8:00 am
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?
Re: issue-#125 Compiler TRAP for WITH statement
Posted: Fri Aug 26, 2016 8:16 am
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
Re: issue-#125 Compiler TRAP for WITH statement
Posted: Fri Aug 26, 2016 8:30 am
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.)
Re: issue-#125 Compiler TRAP for WITH statement
Posted: Fri Aug 26, 2016 8:56 am
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