From: ara howard Date: 2008-02-29T02:29:37+09:00 Subject: Re: Named sprintf parameters On Feb 28, 2008, at 9:57 AM, Trans wrote: > I have a question and perhaps a bit of challenge for those with mad > parse skills: Has anyone ever considered named parameters for sprintf/ > printf? It would be quite useful (to me at least) to be able to do: > > "I am %(name)s." % { :name => "Tom" ] > > Has anyone worked on something like this before? Is there anything > equivalent in the Perl world or other language? I realize we can use > numerals to identify the substitutions, but I feel the labels are much > more readable. Moreover, ultimately it would be interesting to see: > > "I am %(name)s." % binding > > Making use of the binding's local_variables. > > The challenge, of course, is to override printf/sprintf to do this > (the binding part gets you extra ruby points ;-) Even more > challenging, augment the C code to handle it and submit it as a patch. > > T. > class String module M def % *args newstuff super end end include M end a @ http://codeforpeople.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama