Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If a macro returns a function, call it. #188

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion bin/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,12 @@ var expand_definition = function (__x46) {
return ____x49;
};
var expand_macro = function (form) {
return macroexpand(expand1(form));
var __result = expand1(form);
if (function63(__result)) {
return __result(form);
} else {
return macroexpand(__result);
}
};
expand1 = function (__x51) {
var ____id4 = __x51;
Expand Down
7 changes: 6 additions & 1 deletion bin/compiler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,12 @@ local function expand_definition(__x46)
return ____x49
end
local function expand_macro(form)
return macroexpand(expand1(form))
local __result = expand1(form)
if function63(__result) then
return __result(form)
else
return macroexpand(__result)
end
end
function expand1(__x51)
local ____id4 = __x51
Expand Down
3 changes: 2 additions & 1 deletion compiler.l
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@
`(,x ,name ,args ,@(macroexpand body))))

(define expand-macro (form)
(macroexpand (expand1 form)))
(let result (expand1 form)
(if (function? result) (result form) (macroexpand result))))

(define-global expand1 ((name rest: body))
(apply (macro-function name) body))
Expand Down