Hi, 2009/7/17 Mark Addleman <mark_addle...@bigfoot.com>
> > > > On Jul 16, 11:50 pm, Laurent PETIT <laurent.pe...@gmail.com> wrote: > > 2009/7/17 Mark Addleman <mark_addle...@bigfoot.com> > > > > > > > > > "The "sufficiently smart compiler" argument > > > comes to mind: if the arglist of a function is known, then surely > > > the > > > compiler should be able to automatically translate named/keyword > > > arguments into an appropriate simple call?" > > > > > That is exactly what motivated me to write this macro. I was pretty > > > sure keyword args could be optimized to exactly the same as positional > > > arguments without much difficulty (although this macro took me an > > > embarrassingly long time to write!). I wish there was a way to hook > > > the reader so that the macro could be called implicitly. It seems > > > that the metadata facility would be a perfect solution to this. If I > > > tag some symbol with metadata {:interpreter named-call}, for example, > > > the reader should delegate to the macro named-call. > > > > Not so easy I think, even if you had that. > > > > How would the hooked-under-the-hoods named-call macro distinguish between > > this call (some-fn :a :b :c :d) (regular call of some-fn body defined for > > arity = 4) from (some-fn :a :b :c :d) (regular call of some-fn body with > > named arguments, for arity = 2) if some-fn is defined for arities 2 and 4 > ? > > I guess I had in mind some kind of chaining mechanism. Suppose named- > call returned the function symbol (followed by the arguments) where > the symbol did not contain the {:interpreter named-call} meta-data. > Then, there is no ambiguity. In both of your examples, the reader > would apply named-call to some-fn+args and named-call would assume > that the args are name value pairs. > > I think there are other (perhaps better) algorithms for chaining. > There's something I don't understand. The {:interpreter named-call} metadata would be placed on the function var, right ? But it would be up to the user, the caller, to choose whether he wants to use named args, or not. So I think my point is still valid, I can't see how this could be made magic without some help from the user. In smalltalk there is no choice (I guess), if named args are defined, you have to use them. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---