Xref: utzoo comp.object:554 comp.lang.c++:5737 Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!wuarchive!decwrl!shelby!neon!max From: max@Neon.Stanford.EDU (Max Hailperin) Newsgroups: comp.object,comp.lang.c++ Subject: Re: Continuations Message-ID: <1989Dec1.205817.5178@Neon.Stanford.EDU> Date: 1 Dec 89 20:58:17 GMT References: <2664@bingvaxu.cc.binghamton.edu> <9624@pyr.gatech.EDU> <1623@odin.SGI.COM> <1989Nov28.183816.15252@odi.com> <9964@june.cs.washington.edu> <1989Nov29.225826.19483@odi.com> <10008@june.cs.washington.edu> <21989@brunix.UUCP> Sender: USENET News System Reply-To: mxh@sumex-aim.Stanford.EDU (Max Hailperin) Organization: Computer Science Department, Stanford University Lines: 28 In article <21989@brunix.UUCP> twl@boojum.UUCP (Ted "Theodore" (W) Leung) writes: >In article <10008@june.cs.washington.edu> peterd@june.cs.washington.edu (Peter >C. Damron) writes: >>4. C and C++ have first class functions. >> ... no closure required ... >It seems like it would be useful to make a distinction between "first >class" functions which require their implementation via a closure, and >those which do not. As an asside to this discussion, it appears to me that closures can be emulated relatively smoothely in C++. The two key features that support this are: 1) The procedure-call operator can be overloaded, so that you can define a class of closure objects which can be called as if they were procedures. The constructor (lambda equivalent) can copy the closed-over variables into slots with the same name, so that then the procedure-call member function can use them. 2) The notion of a reference type (explicit aliasing) allows the closures to share mutable variables that are in a common scope. Of course, this is still a bit messy, but nothing compared with emuating closures in C. Also, there are other language features that interact poorly with a higher-order style, limiting the utility. I haven't actually used this technique (I'm lucky enough to have a real lisp, instead of having to make C++ pretend it's one). I'd be very interested to hear from anyone who has. Brought to you by Super Global Mega Corp .com