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

Re: Is Dylan a functional language?



On Tue, 09 Oct 2001 16:28:37 GMT, Brian Rogoff <bpr@shell5.ba.best.com> wrote:
>On Tue, 9 Oct 2001, Bruce Hoult wrote:
>> In article <3BC2532B.5030707@staffware-spokane.com>, Doug Hockin
>> <dhockin@staffware-spokane.com> wrote:
>>
>> > Should Dylan show up in this list of functional languages?
>> >
>> > http://dmoz.org/Computers/Programming/Languages/Functional/
>
> What is a "functional language"? To me, it has less to do with being
> side-effect free than with providing "first class" functions. I would
> also add block structure and lexical scope as criteria to really be a
> functional language. Does Dylan have first class functions, block
> structure, and lexical scope? Yes, so I'd put it in there without
> hesitation.

Yes, yes, yes, and me too. :)

>> Like them Dylan has all the features needed to be used in a purely
>> functional style, but doesn't force you into programming that way.
>
> A more interesting question IMO is to what extent a functional style
> is used in common Dylan programming. My OCaml style is largely
> functional but there is almost *always* some bit of imperative code,
> and the use of exceptions (which some people, not me, consider
> non-functional).

Honestly, my Dylan code is more functional than my Ocaml code. This is
because I find it easier to write in a state-passing or monadic style
in Dylan than in Caml.

I find Dylan nicer for writing state-passing code because of a nasty
habit: I care about memory allocation. Dylan's multiple return values
can be stack allocated, whereas using a tuple won't be. Even though I
*know* that I shouldn't care, I do. :) The combination of generic
functions makes a modular monadic style almost ridiculously easy to
do. I tend to cheat a bit, and use macros to eliminate the overhead of
a monadic style, too.

What I really miss in Dylan is cheap keyword arguments as in Ocaml.
Labeled arguments are pretty much always the right way to go, except
that I don't trust the Dylan compiler to optimize them as well as in
Caml.  Garrigue wrote a paper on the label calculus showing how to
efficiently compile curried keyword functions, and that makes me feel
better. I also miss the really static typing, and the parametric
polymorphism (Dylan uses dynamic typing plus I guess parts of a
metaobject protocol to simulate this. It works fine, but I miss the
compile-time guarantees.)

An interesting toy langauge is Danniel Bonniot's Nice language.  It's
an extension to Java that adds static typing, multimethods, first
class functions, parametric polymorphism, and keyword arguments to
Java.

  http://www.sourceforge.net/projects/nice

I expect its design is of some interest to Dylan hackers.


Neel



Follow-Ups: References: