Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!njin!uupsi!sunic!lth.se!newsuser From: bengtl@maths.lth.se (Bengt Larsson) Newsgroups: comp.lang.misc Subject: Re: Algol, and language design Message-ID: <1990Jul27.010930.12560@lth.se> Date: 27 Jul 90 01:09:30 GMT References: <25630@cs.yale.edu> <58091@lanl.gov> <1990Jul26.024449.1777@esegue.segue.boston.ma.us> <2406@l.cc.purdue.edu> Sender: newsuser@lth.se (LTH network news server) Reply-To: bengtl@maths.lth.se (Bengt Larsson) Organization: Lund Institute of Technology, Sweden Lines: 98 In article <2406@l.cc.purdue.edu> cik@l.cc.purdue.edu (Herman Rubin) writes: >In article <1990Jul26.024449.1777@esegue.segue.boston.ma.us>, johnl@esegue.segue.boston.ma.us (John R. Levine) writes: >> How about nested scopes and recursion? I find them handy from time to time. > >Nested scopes of DO loops are present in Fortran. Mathematicians have used Really, Mr Rubin. If you think that nested DO loops in Fortran have anything to do with the nested scopes of (for example Algol, Pascal, Ada), you apparantly don't know what you are talking about. (It is the _block structure_ that is important (several levels of declarations in different scopes). A nested DO loop is, as far as I can see, exactly equivalent to a nested loop in assembler. A nested scope in an Algol-like language is something completely different.) >recursion for ages, and the problems with implementing recursion in the >architecture of the time were horrendous. Frankly, some of them still are. Yes, of course some architectures made (make??) it somewhat difficult to have recursive procedures (the ones that stored the return adress in the first word of the subroutine comes to mind). You can write recursive programs in standard Fortran, but you will have to manage the activation stack yourself. This will certainly not be pretty (compare this with the ease of doing recursive procedures in Algol) >What language allows carrying globals in registers across recursion? I think you are over-concerned about keeping everything in registers. This is a very low-level view, and has almost nothing to do with the advantages/disadvantages (from a software engineering standpoint) of nested scopes as introduced by Algol. >One of the things which should be noted was that, at the time, registers >were few and transfer and memory access were relatively fast compared with >computation. Nobody would have considered the above question of any >importance. Self-modifying code was a necessity, and even a decade later, >the return jump (subroutine call) automatically did so. > >> I'd also be interested to hear what about compound statements (by which I >> presume you mean BEGIN ... END blocks) is bad, and whether the Algol 68 >> approach in which every control structure has its own closing word, obviating >> begin and end, is any better. > >I do not see IF and FI as any better than BEGIN and END. Better would be >to have labels (including temporary labels not going into the symbol table) >and end statements which would carry the label. The END statement, even >without a BEGIN statement, was in common use at the time; All processors >need to know when to stop. It seems you haven't heard about Ada. In Ada, different constructs (loops and blocks come to mind) may have labels. Like: MAIN_LOOP: loop -- stuff SUB_LOOP: loop -- more stuff exit MAIN_LOOP; -- exit 2 levels of loop end loop SUB_LOOP; end loop MAIN_LOOP; If a loop is started by a label and a ":", the same label must be repeated after "end loop". The "exit" statement by default exits one level of loops, it may also exit to a named level, as in the example. All constructs have their own (two word) delimiter, like: if A < B then -- something end if; case MYVAR is when 1 => DO_1; when others => null; end case; select -- end select; Even if Ada isn't best at everything, I think they got the syntax right. I like "if then else end if" better than "if then begin end else begin end". -- Bengt Larsson - Dep. of Math. Statistics, Lund University, Sweden Internet: bengtl@maths.lth.se SUNET: TYCHE::BENGT_L