[fpc-pascal] else and otherwise in a case statement
I've been doing a bulk replace of 'case..else' to 'case..otherwise' to eliminate possible ambiguities that have bitten me in the past, and have noticed something interesting under 2.6.4 on x86 Linux. This is OK: Ord('.'): case shiftState of unshifted: mechCode := Corr_88_Period; shifted: else end; This is an error: Ord('.'): case shiftState of unshifted: mechCode := Corr_88_Period; shifted: otherwise end; I can fix it like this: Ord('.'): case shiftState of unshifted: mechCode := Corr_88_Period; shifted: ; otherwise end; But that grates since I was brought up on ; being a statement separator rather than a terminator. Alternatively this is OK: Ord('.'): case shiftState of unshifted: mechCode := Corr_88_Period; shifted: end; but I like having the regular code (in some cases there are active otherwise clauses, and I spent enough time with Modula-2 to prefer enumerating all possibilities). Is this difference expected, and what is the best workaround? -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] else and otherwise in a case statement
On 11/12/2014 21:07, Mark Morgan Lloyd wrote: I've been doing a bulk replace of 'case..else' to 'case..otherwise' to eliminate possible ambiguities that have bitten me in the past, and have noticed something interesting under 2.6.4 on x86 Linux. How can else be ambiguous within a case statement? Howard --- This email has been checked for viruses by Avast antivirus software. http://www.avast.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] else and otherwise in a case statement
On 12/11/2014 11:13 PM, Howard Page-Clark wrote: On 11/12/2014 21:07, Mark Morgan Lloyd wrote: I've been doing a bulk replace of 'case..else' to 'case..otherwise' to eliminate possible ambiguities that have bitten me in the past, and have noticed something interesting under 2.6.4 on x86 Linux. How can else be ambiguous within a case statement? If one omits the trailing semicolon (the one that's commented), the else becomes ambiguous: Case Something of Value1: ; Value2: If Condition Then DoSomething (*;*) Else End; -- Ewald ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] else and otherwise in a case statement
Ewald wrote: On 12/11/2014 11:13 PM, Howard Page-Clark wrote: On 11/12/2014 21:07, Mark Morgan Lloyd wrote: I've been doing a bulk replace of 'case..else' to 'case..otherwise' to eliminate possible ambiguities that have bitten me in the past, and have noticed something interesting under 2.6.4 on x86 Linux. How can else be ambiguous within a case statement? If one omits the trailing semicolon (the one that's commented), the else becomes ambiguous: Case Something of Value1: ; Value2: If Condition Then DoSomething (*;*) Else End; Yes, that's the one. When I raised it it was pointed out to me that the otherwise form was intended as a drop-in replacement to avoid this. -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal