Jordi Guillaumes i Pons
j...@jordi.guillaumes.name
HECnet: BITXOW::JGUILLAUMES


> 
> I was also going to point out that neither {} nor [] exist in (System/360 era)
> EBCDIC, so could not have been used in PL/1.
> 
> PL/1 (or PL/I, to use the later naming convention) has both BEGIN/END and
> DO/END, with different effects.  I got a long lecture from an office mate once
> about a program which was using BEGIN/END where DO/END was preferable, because
> BEGIN blocks actually create a new context, with internal/external scope
> details, while DO blocks do not create a new context.

There are no curly braces on any PL/I version that I’m aware of. 

The “normal” way to build statement blocks is DO/END, with are just combined 
statements (so can be used in IF…ELSE… or WHILE blocks; PL/I has no ‘END IF nor 
‘END WHILE’ statements). BEGIN/END create a semantic context where you can 
define local variables or, more usefully, establish local condition handlers.

A way to do a controlled check for overflow is, for instance

…
BEGIN;
    DECLARE IS_OVERFLOW BIT(1) INIT(‘0’B);
    ON OVERFLOW IS_OVERFLOW = ‘1’B;
    NUMBER = BIGNUMBER1 + BIGNUMBER2;
    IF IS_OVERFLOW THEN CALL HANDLE_OVERFLOW();
END;
…

That “ON” condition is only valid inside the BEGIN/END block, so if an OFL 
condition occurs elsewhere (and you have used the correct compiler options) the 
program will crash (“ABEND”, in IBM idiom). That is actually what you really 
WANT to happen (better to get a call at 3am than to have to correct a corrupt 
file).




Jordi Guillaumes i Pons
j...@jordi.guillaumes.name
HECnet: BITXOW::JGUILLAUMES
_______________________________________________
Simh mailing list
Simh@trailing-edge.com
http://mailman.trailing-edge.com/mailman/listinfo/simh

Reply via email to