home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.arch      Apparently more than just beeps & boops      131,241 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 130,197 of 131,241   
   Bill Findlay to Anton Ertl   
   Re: label variables, was branch splittin   
   07 Nov 25 17:54:33   
   
   From: findlaybill@blueyonder.co.uk   
      
   On 7 Nov 2025, Anton Ertl wrote   
   (in article<2025Nov7.162638@mips.complang.tuwien.ac.at>):   
      
   > John Levine  writes:   
   > > In languages with nested scopes, label gotos   
   > > can jump to an outer scope so they have to unwind some frames. Back when   
   > > people used such things, a common use was on an error to jump out to some   
   > > recovery code.   
   >   
   > Pascal has that feature. Concerning error handling, jumping to an   
   > error handler in a statically enclosing scope has fallen out of   
   > favour, but throwing an exception to the next dynamically enclosing   
   > exception handler is supported in a number of languages.   
   >   
   > > Function pointers have a sort of similar problem in that they need to carry   
   > > along pointers to all of the enclosing frames the function can see. That is   
   > > reasonably well solved by displays, give or take the infamous Knuth man or   
   > > boy   
   > > program, 13 lines of Algol60 horror that Knuth himself got the results   
   > > wrong.   
   >   
   > Displays and static link chains are among the techniques that can be   
   > used to implement static scoping correctly, i.e., where the man-or-boy   
   > test produces the correct result. Knuth initially got the result   
   > wrong, because he only had boy compilers, and the computation is too   
   > involved to do it by hand.   
      
   I append a run of MANORBOY in Pascal for the KDF9.   
   No display was used.   
   A static frame pointer as part of the functional parameter   
   suffices logically and gives better performance.   
      
   Paskal : the KDF9 Pascal cross-compiler V19.2a, compiled ... on 2025-11-07.   
   1 u | %storage = 32767   
   2 u | %ystores = 30100   
   3 u |   
   4 u | program MAN_OR_BOY;   
   5 u |   
   6 u | { See: }   
   7 u | { "Man or boy?", }   
   8 u | { by Donald Knuth, }   
   9 u | { ALGOL Bulletin 17.2.4, p7; July 1964. }   
   10 u |   
   11 u | var   
   12 u | i : integer;   
   13 u | function A (   
   14 u | k : integer;   
   15 u | function x1 : integer;   
   16 u | function x2 : integer;   
   17 u | function x3 : integer;   
   18 u | function x4 : integer;   
   19 u | function x5 : integer   
   20 u | ) : integer;   
   21 u |   
   22 u | function B : integer;   
   23 u 1b| begin   
   24 u | k := k - 1;   
   25 u | B := A (k, B, x1, x2, x3, x4);   
   26 u 1e| end { B };   
   27 u |   
   28 u 1b| begin { A }   
   29 u | if k <= 0 then   
   30 u | A := x4 + x5   
   31 u | else   
   32 u | A := B;   
   33 u 1e| end { A };   
   34 u |   
   35 u | function pos_one : integer;   
   36 u | begin pos_one := 1 end;   
   37 u |   
   38 u | function neg_one : integer;   
   39 u | begin neg_one := -1 end;   
   40 u |   
   41 u | function zero : integer;   
   42 u | begin zero := 0 end;   
   43 u |   
   44 u 1b| begin { MAN_OR_BOY }   
   45 u | rewrite(1, 3);   
   46 u | for i := 0 to 11 do   
   47 u | write(A(i, pos_one, neg_one, neg_one, pos_one, zero):6);   
   48 u | writeln;   
   49 u 1e| end { MAN_OR_BOY }.   
      
   Compilation complete : 0 error(s) and 0 warning(s) were reported.   
   ...   
   This is ee9 17.0a, compiled by GNAT ... on 2025-11-07.   
   Running the KDF9 problem program Binary/MANORBOY   
   ...   
   Final State: Normal end of run.   
   ...   
   LP0 on buffer #05 printed 1 line.   
      
   LP0:   
   ===   
   1 0 -2 0 1 0 1 -1 -10 -30 -67 -138   
   ===   
   --   
   Bill Findlay   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca