Arc Forumnew | comments | leaders | submitlogin
Lisp-style function definitions
2 points by radetsky 6033 days ago | 4 comments
Can anyone tell me the reasoning behind why arc has gone with lisp-style function definitions, i.e.

(def foo (x y) <body>)

instead of scheme-style function definitions:

(def (foo x y) <body>)?

Lisp-style seems to have the feature that function definitions have greater resemblance to anonymous functions, but this isn't necessarily an advantage (although I think it is).

On the other hand, scheme-style definitions have the advantages that they look less like non-function definitions. They also look more like calls, making it easier to think of them in terms of substitution, but I'm not convinced that this is an advantage just yet.

Also, they're a lot easier to translate into scheme ;)

Thoughts?



4 points by almkglor 6033 days ago | link

Slightly easier to type "/def foo" or "/mac foo" in vim.

-----

4 points by PieSquared 6033 days ago | link

I think it's just because many people are used to having the arguments declared separately from the name, since most other languages (including non-Lisps) do that as well.

-----

3 points by tokipin 6032 days ago | link

remember also that Arc autodestructurizes arguments based on the parameter list (example: http://arclanguage.org/item?id=6125.) scheme-style def would would conceptually interfere with that

though maybe scheme autodestructurizes like that also? i don't know

-----

1 point by conanite 6032 days ago | link

arc lets us write

  (def foo args ...

  (def foo (x y . rest) ...
so that args is the list of all arguments, and rest is the list of all arguments after the first two. I suppose the equivalent scheme-ish way would be

  (def (foo . args) ...

  (def (foo x y . args) ...
I like the fact that arc has no special &rest keyword, that rest args just fall out of the way lists are constructed.

I haven't used scheme so I'm not qualified to comment (but obviously that's not stopping me), but to this n00b it makes sense that the parameter list is distinct from the function name. And as you mention it makes named functions look more similar to anonymous functions. So I have less thinking to do when I'm looking at a parameter list.

-----