[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: What's so cool about Scheme?

Mike Newhall wrote:
> 	As an aside, why first-class functions?  I think first
> class functions are incredibly useful in general, but, strictly
> speaking, isn't functional programming just programming without
> side effects and all the benefits that brings, and thus why can't
> you do that without passing functions around?  Or is the idea of
> higher-order programming [arbitrarily] bundled into the idea of
> functional programming?

Lambda calculus clearly illustrates that this isn't an arbitrary connection.
In the lambda calculus, literally every piece of data is a function, and LC
could not exist without higher-order functions.  LC is the prototypical
functional language, which defines many of the characteristics which all
functional languages share.  All functional languages I'm familiar with
derive their core model from it (including Lisp; McCarthy semi-reinvented
parts of lambda calculus, complete with HO functions).  It makes sense that
higher-order functions are an integral part of the design of these

Of course, real functional languages have data types other than functions,
and so presumably could get away without HO functions, in theory.  But that
would prevent many of the things which a pure functional language allows:
operations such as maps and folds would have to be implemented iteratively,
for example.  You would lose the ability to write generic code that is
parameterized by functions, and would be reduced to relying on things like
case/switch statements, very much along the lines of pre-OO imperative
languages.  You would be left with a very impoverished language in which you
could not easily reuse a function in any context other than calling it
directly and explicitly.  Such a restricted variety of functional
programming would be hard to defend against alternatives such as OO.

> The general idea is simply that the bundle of ideas represented
> by the design of the LISP family of languages is important, but
> seems to have no name.

Its name is "Lisp".  Or, as I like to call it, "Scheme".  ;-)

> Other languages also possess many of the same qualities of LISP
> and Scheme.  These languages are often labeled 'functional';
> perhaps the whole 'functional programming languages' field should
> bifurcate into *true* functional languages and those that have
> the 'LISP quality', whatever people want to call it.

One way to look at it the code=data aspect of the 'LISP quality' is that
pure functional programming treats functions as data, but does so with the
function as a semantic entity.  Lisp/Scheme takes this a step further,
treating a function's syntactic representation as data, providing a
interface for manipulating it consistent with other data in the language,
and providing the ability to create functions from their syntactic
representation, at runtime.  There's not much inherently functional about
it, but it's an extension in a  natural direction for a functional language:
extending the manipulation of functions as data, into the syntactic realm.