Skip to content

Instantly share code, notes, and snippets.

@delonnewman
Last active March 7, 2016 22:01
Show Gist options
  • Save delonnewman/b71e551d242929861f5c to your computer and use it in GitHub Desktop.
Save delonnewman/b71e551d242929861f5c to your computer and use it in GitHub Desktop.
Some macros written in WonderScript as JavaScript data structures (found in the core library).
ws.eval(
['defmacro', 'let', ['form'],
['do',
['def', 'bindings',
['map', ['pair', ['form', 1]] , ['fn', ['x'], ['.concat', ['array', '`def'], 'x']]]],
['def', 'exprs', ['.slice', 'form', 2]],
['.concat', ['array', '`do'], 'bindings', 'exprs']]]);
ws.eval(
['defmacro', 'deftype', ['form'],
['list', ['symbol', '"def"'], ['form', 1],
['.concat', ['list', ['symbol', '"dataType"']], ['.slice', 'form', 2]]]]);
ws.eval(
['defmacro', 'defprotocol', ['form'],
['list', ['symbol', '"def"'], ['form', 1],
['.concat', ['list', ['symbol', '"protocol"']], ['.slice', 'form', 2]]]]);
ws.eval(
['defmacro', 'while', ['form'],
['list', ['symbol', '"doWhile"'],
['list', ['symbol', '"fn"'], ['list'], ['form', 1]],
['list', ['symbol', '"fn"'], ['list'], ['form', 2]]]]);
ws.eval(
['defmacro', 'until', ['form'],
['list', ['symbol', '"doWhile"'],
['list', ['symbol', '"fn"'], ['list'],
['list', ['symbol', '"not"'], ['form', 1]]],
['list', ['symbol', '"fn"'], ['list'],
['.concat', ['list', ['symbol', '"do"']], ['.slice', 'form', 2]]]]]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment