Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!news.mathworks.com!newsfeed.internetmci.com!in1.uu.net!netnews.jhuapl.edu!aplcenmp!wb3ffv!usenet
From: vanyo@ibcco.com (Bill Vanyo)
Subject: Re: no more lisp!
Sender: usenet@abs.net
Message-ID: <DoMuny.2zI@abs.net>
Date: Wed, 20 Mar 1996 19:43:45 GMT
X-Nntp-Posting-Host: ppp-163.ezaccess.net
References: <DoD65D.LrE@abs.net> <4ige8c$6io@news1.h1.usa.pipeline.com> <raffael-2003951649060001@macav.tiac.net> <wnewmanDoLouI.4tB@netcom.com>
Organization: ABSnet Internet Services, Inc. - info@abs.net - (410)-361-8160
X-Newsreader: Forte Free Agent 1.0.82
Lines: 55

wnewman@netcom.com (Bill Newman) wrote:

>Raffael Cavallaro (raffael@tiac.net) wrote:

[much clipped]

>You may be slightly confused about the difference between C and C++.
>Alternatively, you may have a very narrow, technical definition of 
>lexical closures -- if you want something that specifically bundles
>up the lexical environment, then you're right, C++ doesn't do it that
>way.  But it's reasonably straightforward to write the equivalent
>of ``addn'' in C++ -- see the example program after my sig.  (BTW,
>I think you're also right that closures can't be done in Pascal,
                                                          ^^^^^^
>but I'm pretty sure that the C++ program below could be translated
>into Ada95 without much difficulty.  If you agree not to pick on
>20-year-old strongly-typed languages, I'll try not to pick on 
>pre-Common-Lisp Lisp.:-)

Pascal does implement functions passed as parameters as closures. But
there are, of course, no "upward closures", i.e. functions returned
from functions (only downward - passed to).
This is not true for Borlands in-name-only Pascal.
And Pascal programmers are generally unaware of what a closure is.

Ex. Pascal program to print out 10*15 multiplication table:


program TimesTable(input,output);

procedure DoTimes(procedure P(n:integer); T:integer);
var i:integer;
begin
  for i:=1 to T do P(i);
end;

procedure PrintTable(numrows,numcols:integer);
 procedure PrintRow(row:integer);
   procedure PrintElement(column:integer);
   begin
     write(row*column:5);
   end;
 begin
   DoTimes(PrintElement,numcols);
   writeln;
 end;
begin
 DoTimes(PrintRow,numrows);
end;

begin
  PrintTable(10,15);
end.


