-1, because it’s already easy to add singleton methods and/or build
proper wrapper classes with delegation - and the latter is usually a
better solution longer-term (*)
I do think that << should be more widely implemented: e.g. in Proc as an
alias for #call, and in Hash for ‘add [key,value] pair’, so it becomes
more useful for duck-typing. But I don’t think that’s the point you’re
trying to make here.
Regards,
Brian.
(*) For example, the ‘entries’ proxy you return currently only
implements #<<. What if you later want it to implement #size or #empty?
or #first or …
Also, objects with singleton classes cannot be marshaled.
-1, because it’s already easy to add singleton methods and/or build
proper wrapper classes with delegation - and the latter is usually a
better solution longer-term (*)
The question is whether you always need a long term solution. We’re
not all building long term applications with Ruby. And if there is a
feature which makes hacking scripts easier and does not hurt
application development, then why not?
I do think that << should be more widely implemented: e.g. in Proc as an
alias for #call, and in Hash for ‘add [key,value] pair’, so it becomes
more useful for duck-typing. But I don’t think that’s the point you’re
trying to make here.
That’s an interesting point! Then I would also ask for === to be an
alias for Proc#call by default. But wait: and what about +, - etc.?
(*) For example, the ‘entries’ proxy you return currently only
implements #<<. What if you later want it to implement #size or #empty?
or #first or …
Then you just exchange the implementation and use Delagator or
something similar.
Also, objects with singleton classes cannot be marshaled.
True but I don’t see that as an argument against providing such a
method. Otherwise Hash would not be allowed a default_proc either.
Kind regards
robert
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.