Thanks - that's just what I needed to know :-) On Tuesday, March 18, 2014 12:40:36 AM UTC+2, tbc++ wrote: > > The problem is in the way lisp compilers work. Example: > > The public macro gets analyzed first and runs, and emits the code required > to call the private macro. Then the compiler analyzes the output of the > first macro and discovers that the code now calls a new macro. It analyzes > this code and finds a call to a private var and dies. > > Macros are evaluated one at a time outer forms to inner forms. This is > pretty much the opposite from normal evaluation that happens from the > inside out. > > Timothy > > > On Mon, Mar 17, 2014 at 4:29 PM, Yoav Rubin <[email protected]<javascript:> > > wrote: > >> Let's leave aside the recommendations not to do it. I'd like to >> understand why I get the exception when I make such a call (from a public >> macro to a private macro), and if it is possible, what am I doing wrong >> here... >> >> On Monday, March 17, 2014 7:40:42 PM UTC+2, tbc++ wrote: >> >>> Don't use private vars. Instead move the macro to a sub namespace called >>> "internals" or "impl" or something like that and make it public. Prefer >>> trusting your users instead of limiting them. >>> >>> my $0.02 >>> >>> Timothy >>> >>> >>> On Mon, Mar 17, 2014 at 11:33 AM, Yoav Rubin <[email protected]> wrote: >>> >>>> I'm familiar with that trick, but is it a language feature (and then I >>>> can rely on to not being changed in the future)? or is it a hack that >>>> based >>>> on something that may change in future releases? >>>> >>>> Thanks, >>>> >>>> Yoav >>>> >>>> >>>> On Monday, March 17, 2014 4:09:23 PM UTC+2, Maik Schünemann wrote: >>>> >>>>> Hi, >>>>> I guess that maybe the same trick works for calling private functions >>>>> from another namespace via getting the var and calling it. >>>>> That being said, macros calling macros gets very complex after a short >>>>> time, it is better to have helper functions instead of macros. >>>>> The functions just accept s-expressions and return s-expressions. I >>>>> find myself doing exactly that for nontrivial macros. >>>>> >>>>> Hope that helps, >>>>> Maik >>>>> >>>>> On Mon, Mar 17, 2014 at 7:02 AM, Yoav Rubin <[email protected]> >>>>> wrote: >>>>> > Hi All, >>>>> > >>>>> > I have a namespace that has two macros as part of its public API, >>>>> and >>>>> > another macro that act as helpers for the public macro >>>>> > >>>>> > (defmacro helper-mac [arg1 arg2 f] >>>>> > ;; do stuff with f , arg1 and arg2 >>>>> > ) >>>>> > >>>>> > (defmacro m0 [arg1 arg2] >>>>> > (priv-mac arg1 arg2 f1) >>>>> > ) >>>>> > >>>>> > (defmacro m1 [arg1 arg2] ( >>>>> > (priv-mac arg1 arg2 f2) >>>>> > ) >>>>> > >>>>> > f1 and f2 are just two functions. >>>>> > >>>>> > I would like to make the helper macro private (using ^:private), >>>>> but when I >>>>> > do it and call either m0 or m1 from another namespace, I get an >>>>> exception >>>>> > saying that helper-mac is private. >>>>> > >>>>> > Is it possible to call from to a macro in another namespace when >>>>> that macro >>>>> > is calling a private macro in its namespace? >>>>> > >>>>> > Thanks, >>>>> > >>>>> > Yoav >>>>> > >>>>> > -- >>>>> > 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 >>>>> > --- >>>>> > You received this message because you are subscribed to the Google >>>>> Groups >>>>> > "Clojure" group. >>>>> > To unsubscribe from this group and stop receiving emails from it, >>>>> send an >>>>> > email to [email protected]. >>>>> > For more options, visit https://groups.google.com/d/optout. >>>>> >>>> -- >>>> 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 >>>> --- >>>> You received this message because you are subscribed to the Google >>>> Groups "Clojure" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> >>> >>> -- >>> “One of the main causes of the fall of the Roman Empire was that–lacking >>> zero–they had no way to indicate successful termination of their C >>> programs.” >>> (Robert Firth) >>> >> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to [email protected]<javascript:> >> 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] <javascript:> >> For more options, visit this group at >> http://groups.google.com/group/clojure?hl=en >> --- >> You received this message because you are subscribed to the Google Groups >> "Clojure" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > “One of the main causes of the fall of the Roman Empire was that–lacking > zero–they had no way to indicate successful termination of their C > programs.” > (Robert Firth) >
-- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
