Closed spy16 closed 4 years ago
@lthibault Macro support has been added in 83f8103 . It's not well tested yet. But seems to work 😄 . Do try it out and let me know when you get a chance.
@spy16 Very cool!
I've had a look, but I'm not sure what kind of useful feedback I can give, as I'm not very knowledgable in the nuances of macro systems (or lisp in general, for that matter).
In lieu of a thoughtful critique, here's a list of questions that popped into my mind as I was reading. Some of these are probably very basic.
What does the terminating-*
convention signify? I'm familiar with the meaning of the "earmuffs" convention (e.g. *ns*
), but not of e.g. let*
.
What is the relationship between macro*
, fn
, defn
and defmacro
?
What is the meaning of &
, and where is it defined? (e.g.: (def defn (macro* defn [name & fdecl] ...
)
What's the rationale behind the SpecialForm
type versus binding a user-defined native Go type to a scope?
In general, I think I'm looking for some insight into the design choices at play. Understanding intent will help use this correctly.
*
I thought of making all special forms have this actually but haven't done that yet. I was thinking of having an alias in lisp code for these special forms that add some documentation also (since no doc string is added from go code. So fn*
would be pure go form and fn
would be wrapped version with documentation. Idea taken from clojure)fn*
and macro*
define a anonymous function and macro respectively. defn
and defmacro
define a function and bind It to a name in the root scope. macro* might go away. &
is for variadic arguments similar to clojure. After &
there can be only one arg which will be assigned the list of all remaining arguments. List.Eval()
. I might merge SpecialForm into Fn to reduce number of types. This is the intermediate parse step I was talking about. Makes sense, thanks for the explanation! This all seems sensible and I don't see anything missing.
I'm currently integrating the changes to Sabre in my project, after which I'll start focusing on the language. I'm certain I'll have some feedback at this point (albeit from the trenches!)
MacroFn
invokable value type (i.e., implements bothsabre.Value
andsabre.Invokable
) which expands the macro definition and evaluates when invoked.defmacro
macroexpand