On Sun, 2006-05-28 at 19:58 +0900, Daniel Schierbeck wrote:
> Ross Bamford wrote:
> > On Sun, 2006-05-28 at 19:37 +0900, Daniel Schierbeck wrote:
> >> That's very interesting. Would it be better if class objects were given 
> >> instead of class names? Otherwise it could be tedious to convert to 
> >> A::B::BadgerMilk :)
> > 
> > Good point :) The way it's written, you can do that already, since the
> > 'syms' are all to_s'd anyway.
> > 
> > $intclz = Integer		# just for example
> > 
> > def ameth(foo, bar, baz, &blk)
> >   argsto($intclz, String, :sym)
> >   blk.call(foo, bar, baz)
> > end
> 
> I don't think that'll work with "nested" constants, i.e. A::B::C. I 
> think it may complicate things too much to allow classes/class names -- 
> besides, it should be the arguments, not the classes, that should handle 
> the conversion.

Actually, the classes aren't handling the conversion - it's just calling
the standard coercion methods (String(), Integer(), etc). So you'd
probably have to define a BadgerMilk() method. Failing that, you just
pass lowercase names to get the (less strict) to_whatever conversion,
handled as you say by the arguments themselves, i.e. you could also do a
to_badgermilk where it made sense, and call argsto(:badgermilk) ).

Anyway, I did say it was a naive implementation ... :)

-- 
Ross Bamford - rosco / roscopeco.REMOVE.co.uk