[comp.compilers] first class functions

budd@mist.CS.ORST.EDU (Tim Budd) (04/28/89)

[first message]
I'm looking for examples (if any) of any compiled, possibly strongly typed,
languages in which functions/procedures are first class values (i.e., can be 
stored in variables, can be sent as arguments to other functions, can be 
returned as the result of a function, and so on).

I'm currently designing and implementing such a thing, and want to know
what previous work has been done.

[second message, combined via the magic of moderated news groups]
oops.

After pondering for ten more minutes after I posted my earlier note about
langauges with first class functions I realized my question was either
unclear or trivially obvious (take your pick). I realized that being able 
to assign functions to variables, return them from functions, and so on 
isn't really the issue.
You can do all that in C, but that doesn't make functional programming in C
similar to functional programming in, say, scheme or ISETL.
Try writing a curry-ing function in C, for example, and you can see what I
mean.  The reason why C functions aren't as useful (in this case) is that
C functions can't be nested, and thus don't have to remember their state.
Nested functions bring on upward and downward funarg problems, but that
isn't the same thing as being able to assign a function to a variable.

so my question boils down to asking for compiled languages that have nested
functions and first class functions, and thus have to deal with funarg
(functional argument) problems; and how they do it.  And actually now that
I think more about it SL5 springs to mind.  Any others?
--(a now red-faced) tim budd;  budd@cs.orst.edu
[Scheme compilers and most Lisp compilers have had to deal with this problem.
Other suggestions as always welcome. -John]
--
Send compilers articles to compilers@ima.isc.com or, perhaps, Levine@YALE.EDU
Plausible paths are { decvax | harvard | yale | bbn}!ima
Please send responses to the originator of the message -- I cannot forward
mail accidentally sent back to compilers.  Meta-mail to ima!compilers-request

kubiak@bach.csg.uiuc.edu (Ken Kubiak) (04/28/89)

I've been looking at a language called Hope from Imperial College, which
is a compiled, _strongly_typed_ true  functional language with true
first class functions.  The excellent book _Functional_Programming_
by Field and Harrison of IC, introduces the language and gives an
in-depth study of how to compile it and anything like it.  An 
implementation for the Suns has been developed by IC, which is supposed
to be very fast.  I can send more details on the Sun version by e-mail.

Ken Kubiak
Computer Systems Group
University of Illinois at Urbana-Champaign
kubiak@csg.uiuc.edu
--
Send compilers articles to compilers@ima.isc.com or, perhaps, Levine@YALE.EDU
Plausible paths are { decvax | harvard | yale | bbn}!ima
Please send responses to the originator of the message -- I cannot forward
mail accidentally sent back to compilers.  Meta-mail to ima!compilers-request