van-wijngaarden-switch.a68

     
   1  COMMENT
   2  
   3  @section Synopsis
   4  
   5  Van Wijngaarden's pseudo-switch.
   6  
   7  The following is derived from
   8  C.H. Lindsey, A History of Algol 68
   9  ACM Sigplan Notices, Volume 28, No. 3 March 1993
  10  
  11  COMMENT
  12  
  13  PRAGMAT quiet regression PRAGMAT
  14  
  15    PR echo "Jumps as row of PROC VOID ... " PR
  16  
  17  # ... But worse! Van Wijngaarden was now able to exhibit his pride and joy -
  18    his pseudo-switch [R8.2.7.2]. #
  19  
  20    [] PROC VOID switch = (e1, e2, e3);
  21  
  22  # ... or even ... #
  23  
  24    LOC [1 : 3] PROC VOID loc switch := (e1, e2, e3);
  25    loc switch[2] := e3;
  26  
  27  # ... To my shame, I must admit that this still works, 
  28    although implementations tend not to support it. #
  29  
  30    switch[2];
  31  
  32    print("Can't be here");
  33  
  34    e3: e2: e1: print ("Jumped correctly");
  35    newline (standout)
  36  
  37  # A68G correctly executes this code #