Are you sure that always works? I think I am misunderstanding Halloway's Taxonomy of Macro's chapter
defstruct is written as a macro and Stuart then comments "This macro looks so simple that you may be tempted to try to write it as a function. You won't be able to because def is a special form. You must generate def at macro time; you cannot make 'dynamic' calls to def at runtime" On May 31, 4:05 pm, Joost <[email protected]> wrote: > On May 31, 4:35 pm, Quzanti <[email protected]> wrote: > > > That was interesting. > > > One more Q. > > > What determines whether special forms can be used in functions eg you > > can't def a variable in a fn. > > You can: > > user> (defn fun [v] (def my-v v)) > user> (fun 'a) > user> my-v > a > user> (fun 'b) > user> my-v > b > > I'm not aware of any special form that can't be used inside a > function. > But I haven't looked for them either. > > > Is it there some rule or is it special form specific depending on > > (a) the intended use of the special form > > (b) the mechanics of getting the compiler to use the special form > > First you'd have to find such special forms. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en
