anko / eslisp

un-opinionated S-expression syntax and macro system for JavaScript
ISC License
528 stars 31 forks source link

capmacro doesn't capture subsequent macros #33

Closed egasimus closed 8 years ago

egasimus commented 8 years ago

This code:

(capmacro Var (lambda (val)
  (return `((require "observ") ,val))))

(capmacro Arr (lambda ()
  (var args (Array.prototype.slice.call arguments 0))
  (return `((require "observ-array") (array ,@args)))))

(capmacro Obj (lambda ()
  (var args (Array.prototype.slice.call arguments 0))
  (return `((require "observ-struct") (object ,@args)))))

(Obj "results" (Arr (Var (Obj "foo" "bar"))))

compiles to:

require('observ-struct')({ 'results': require('observ-array')([require('observ')(Arr(Obj('foo', 'bar')))]) });

rather than:

require('observ-struct')({ 'results': require('observ-array')([require('observ')(require('observ-array')[(require('observ-struct')({ 'foo': 'bar'})]))]) });

What do I do?

vendethiel commented 8 years ago

seems to be a duplicate of #27

anko commented 8 years ago

Yep, as @vendethiel says, this is a different manifestation of the same undelying problem as #27.

I'm almost done with a big rework of the macro API, which will eliminate this problem, among others. Watch #27 for updates.