Skip to content

Conversation

@Gozala
Copy link
Collaborator

@Gozala Gozala commented May 22, 2014

This is work in progress patch. With this extension following code will produce output below it:

(define-macro unless  
  [condition form]
  (list 'if condition nil form ))


(unless weekend? (alarm "8:00"))
(function () {
    var unless = exports.unless = function unless(condition, form) {
            return list(symbol(void 0, 'if'), condition, void 0, form);
        };
    this['user.wisp$unless'] = unless;
    return unless;
})();
isWeekend ? void 0 : alarm('8:00');

Only visible difference is that macro will actually compile to a JS function. This is a step towards implementing macro imports. Now what's left is to extend analyzer (or maybe compiler) so that :require forms from ns will actually be required during compilation. That way macros from those modules will actually be installed. In addition macro expander will have to be modified slightly so that it will look up macros not only in it's own hash map but rather where define-macro installs them: this['user.wisp$unless']. Finally namespace info will have to be preserved on symbols so that in the code (unless weekend? (alarm "8:00")) unless could be mapped back to either local unless or imported one like my.macros/unless which is necessary to properly resolve macros.

@vendethiel
Copy link

That could actually make macro debug much easier too, right ?

@Gozala
Copy link
Collaborator Author

Gozala commented May 22, 2014

That could actually make macro debug much easier too, right ?

I'm not sure it will be make a big difference since most of the time compilation will happen ahead of time, although it may make testing of macros little easier.

@Gozala
Copy link
Collaborator Author

Gozala commented May 22, 2014

Namespace fixes mentioned earlier have being worked on under #103

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants