anko / eslisp-fancy-function

eslisp macro: function expression with argument-splats and implicit return
0 stars 1 forks source link

Fails when nested #1

Open anko opened 9 years ago

anko commented 9 years ago

Reported by @kiasaki in chat.

(var fun (require "eslisp-fancy-function"))
(fun () (fun () x))

—errors when it should give function() { return function() { return x; } }.

stasm commented 9 years ago

I'm not sure if this is specific to the fancy-function macro. I think there might be something wrong with how macros are expended inside other macro calls (not definitions). Consider the following example where fun0 is a macro for defining lambdas which take no arguments:

$ cat fun0.esl
(macro fun0 (lambda (body)
  (return `(lambda () ,body))))
(macro ok (lambda ()
  (return '(return true))))
(fun0 (ok))

$ eslc fun0.esl
(function () {
    ok();
});

I've tried both macro and capmacro and in netiher case is (ok) expanded properly. I would expect something similar to the following snippet, but perhaps I'm wrong?

$ cat lambda.esl
(macro ok (lambda ()
  (return '(return true))))
(lambda () (ok))

$ eslc lambda.esl
(function () {
    return true;
});

I can file a new issue in https://github.com/anko/eslisp if you'd like.