Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

LISP [Part 6]

Name: Anonymous 2008-06-08 17:09

LISP

Name: Anonymous 2008-09-03 16:35

>>830
Would you rather write (list 1 2 3) or (cons 1 (cons 2 (cons 3)))? (printf "~a is ~a~n" name value) or fwrite("~s is ~B!~n", [name, value]) like Erlang1?

You might think polyvariadic functions are just convenient wrappers for special list syntax and functions of fixed arity. You might want to replace them for arity overloading (talk about useless) or automatic currying (just convenience for manual currying). I think that would be a mistake.

When you explicitly call a function (e.g. with S-expressions or M-expressions) you already make a list: the list of arguments. From a design/implementation POV it's very natural to use this for Scheme-style polyvariadic functions2.
Also, polyvariadic functions are very natural to the programmer. When I wrote Erlang, even as I got into it, every second fwrite/format I forgot to wrap the last argument in a list. In Haskell and Factor, the standard library provides map in several numbered forms that work well with currying, but nothing as general as map in Scheme.3

1 http://erlang.org/doc/man/io.html#fwrite-3
2 See SICP lecture 4a, http://video.google.com/videoplay?docid=6196234900528730258
3 Of course it isn't just for convenience: Haskell's type system is too limiting and Factor doesn't really seem to care about more than two lists.
4 Here is a general map for Factor:
: map* ( seqseq quot -- seq ) [ flip ] dip [ [ ] each ] prepose map ;
5 Polyvariadic functions are only tangentially related to the polyvariadic Y combinator.

Newer Posts