syntax for declaring a named (as opposed to anonymous) function?

16 views
Skip to first unread message

Darren Cruse

unread,
Mar 2, 2015, 1:57:21 PM3/2/15
to lispy...@googlegroups.com
Hi was playing with lispyscript yesterday really like how you've kept it so close to javascript.

(I've been learning Racket recently but I know using Racket would be a hard sell with many of my coworkers - I like how Lispyscript has the minimal "lispyness" needed so javascript programmers can still feel at home).

Slightly related to the above:  Anonymous functions are common in javascript but declaring a named function is very common as well.

Is there no syntax for declaring a named function other than assigning an anonymous function to a var?
i.e. something like common lisp's (defun square (x) (* x x)) ?

If it's not there is it because you assumed people might just write a macro to sugar e.g.:

    (function square (x) (* x x))

Into:

    (var square (function (x) (* x x)))

That should be possible right? 

i.e. The symbol following "function" distinguishes it from the anonymous form (where the paren for the arg list follows "function")

Partly just curious if it's there and I overlooked it.

Or if it's not there if you'd be open to me trying my hand at adding it (with the above syntax) and me submitting a pull request.

Darren Cruse

unread,
Mar 8, 2015, 12:10:54 PM3/8/15
to lispy...@googlegroups.com
fyi for anyone following along...

I've implemented named functions in the simple form I mentioned above i.e.:


    (function square (x) (* x x))

I've done it in the master branch I'll be submitting a pull request shortly.

(note the master branch also has the source maps support and I'm not sure what else - i.e. I'm not sure how quickly this will make it in the npm version just fyi)
Reply all
Reply to author
Forward
0 new messages