[Enhancement] Allow passing special forms as functions in macro context
Closed this issue · 3 comments
alexmozaidze commented
It would be nice to have. I've yet to find myself in a strong need for it, but it would remove some boilerplate from small macros such as the following example:
(lambda dec-inc-boilerplate [f idx ?by]
`(set ,idx (,f ,idx ,(or ?by 1))))
(lambda -- [idx ?by]
(dec-inc-boilerplate - idx ?by))
(lambda ++ [idx ?by]
(dec-inc-boilerplate + idx ?by))
Right now, one must copy-paste the body of dec-inc-boilerplate
into those other macros and have the form invocation baked-in:
(lambda -- [idx ?by]
`(set ,idx (- ,idx ,(or ?by 1))))
(lambda ++ [idx ?by]
`(set ,idx (+ ,idx ,(or ?by 1))))
Again, not the end of the world, but would be nice to have ^^
technomancy commented
Turns out this works fine already, you just need to quote the symbol for the special.
(lambda dec-inc-boilerplate [f idx ?by]
`(set ,idx (,f ,idx ,(or ?by 1))))
(lambda -- [idx ?by]
(dec-inc-boilerplate `- idx ?by))
(lambda ++ [idx ?by]
(dec-inc-boilerplate `+ idx ?by))
alexmozaidze commented
Welp, that's an oopsie on my side. Thanks for pointing it out!
technomancy commented
Haha no worries.