Skip to content

Instantly share code, notes, and snippets.

@rizo
Last active December 14, 2015 08:48
Show Gist options
  • Save rizo/5060108 to your computer and use it in GitHub Desktop.
Save rizo/5060108 to your computer and use it in GitHub Desktop.
// (defmacro ex1 (K) `(defun addnumber (X) (+ ,K X) ))
mixin template ex1(alias K)
{
int addnumber(int X)
{
return K + X;
}
}
// (defmacro ex0 (M K) `(progn (macroexpand-1 (,M ,K))))
mixin template ex0(alias M, alias K)
{
mixin M!K;
}
// (ex0 ex1 4)
mixin ex0!(ex1, 4);
void main()
{
assert(addnumber(2) == 6);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment