[plt-scheme] Functions as first class data types.

From: John Clements (clements at brinckerhoff.org)
Date: Tue Feb 17 13:23:38 EST 2009

On Feb 14, 2009, at 8:21 PM, e wrote:

> wow, based on that link, I guess my answer to the "newbie lambda() 
> (??????)" post wasn't that unique.  Here's an excerpt that had to do  
> with *why* (not how) the stop function was tied to the function  
> returned from "server":
>
> "Not only CAN you return a function, the REASON you are in this case  
> is so that its execution will be tied (bound) to the thread that was  
> started.  I am thinking this is an example of a "closure".
>
> I guess in OO, you'd make a server "instance", and it would have a  
> "stop" command . . .. or you could "delete" it (in C++), which would  
> call the "destructor" . . . or in Java, there's some what of an  
> opportunity in "finalize()", but not a reliable one.  In Python, I'm  
> thinking you'd have a "stop", and it'd be obvious that construction  
> and "stopping" aren't symmetric operations.
>
> Now that I've made this comparison, it seems like the argument you  
> have for fp reduces from "you can't do this in OO" to, "you need  
> more boilerplate and fanfare to do it in OO" (possibly a whole file,  
> possibly two -- one for the header and one for the implementation,  
> RAII semantics on the constructor, etc)."

 From Alan Perlis:

Beware of the Turing tar-pit in which everything is possible but  
nothing of interest is easy." --Alan Perlis, "Epigrams on  
Programming" [1].

That is: in any Turing-complete language, you can "do anything you  
want" (that is, you can do all the things you can do in the other  
Turing-complete languages) .  The question is not whether a particular  
language can encode a particular style, but whether it does so in a  
"nice" way.  You can also distinguish languages on the basis of their  
expressiveness--see papers by Felleisen.

John Clements


> On Sat, Feb 14, 2009 at 10:29 PM, Henk Boom <henk at henk.ca> wrote:
> 2009/2/14 Grant Rettke <grettke at acm.org>:
> > On Sat, Feb 14, 2009 at 6:24 PM, aditya shukla
> > <adityashukla1983 at gmail.com> wrote:
> >> Can someone  please explain what's the use of having functions as  
> first
> >> class data type in scheme .I am a little confused about functions  
> having
> >> functions as their arguments .
> >
> > There are problems that you want to solve while programming where  
> you
> > will find that first class functions are one good solution. In their
> > absence there are other good solutions, too.
>
> Other good solutions such as objects:
>
> http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg03277.html
>
>    Henk
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2484 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20090217/a8608391/attachment.p7s>

Posted on the users mailing list.