Xref: utzoo comp.object:553 comp.lang.c++:5733 Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!brunix!twl From: twl@brunix (Ted "Theodore" (W) Leung) Newsgroups: comp.object,comp.lang.c++ Subject: Re: Continuations Message-ID: <21989@brunix.UUCP> Date: 1 Dec 89 17:19:49 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> Sender: news@brunix.UUCP Reply-To: twl@boojum.UUCP (Ted "Theodore" (W) Leung) Organization: Brown University Department of Computer Science Lines: 27 In article <10008@june.cs.washington.edu> peterd@june.cs.washington.edu (Peter C. Damron) writes: >4. C and C++ have first class functions. Functions can be passed as > parameters, returned as function values, and assigned to variables. > The reason that C and C++ do not allow nested functions is precisely > so that they can have first-class functions implemented on a stack > (e.g. no closure required). The "parent block" of a function is > simply the global variables. > 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. There is a fairly standard trick in the Scheme community, which uses closures to create objects. The closed over variables are used to represent the local state of the object, and the code of the closure is a big case statement which selects the correct method to be invoked. It seems to me that you cannot use C "first class" functions to create objects, because they have no closure..... I do think that C/C++ functions are not first class because it is not possible to create a function on the fly the way that you can in LISP or Scheme. Ted -------------------------------------------------------------------- Internet/CSnet: twl@cs.brown.edu | Ted "Theodore" Leung BITNET: twl@BROWNCS.BITNET | Box 1910, Brown University UUCP: uunet!brunix!twl | Providence, RI 02912 Brought to you by Super Global Mega Corp .com