I can't remeber if this was discussed in the past,
but I just noticed that it's possible to define
a method with an invalid name bypassing the syntactic
check via define_method, i.e.
>> class C
>> define_method " ^_^ " do "happy!" end
>> end
=> #<Proc:0x02988088@(irb):6>
>> C.new.send " ^_^ "
=> "happy!"
(works in 1.8, untested on cvs HEAD)
I think this behaviour should be prohibited
(but on the other hand it opens great possibilities :)
C.new."^_^"
That could be helpful for DSLs. This would allow for a much closer E4X
implementation for instance.
xml."@attribute"
T.
I think methods-which-do-the-same-as-some-syntax[1] should behave
accordingly to that.
Say, delegate.rb uses #eval to define methods.
The Evil Eval could probably be replaced with define_method,
but the behaviour could be different since #eval locks out invalid
methods with a SyntaxError, while define_method accepts them.
> Unfortunately there's not a whole lot to do with it except to "hide"
> methods. I'd like to see this:
>
> C.new."^_^"
>
> That could be helpful for DSLs. This would allow for a much closer E4X
> implementation for instance.
>
> xml."@attribute"
well, I think most reasonable DSLs should use proper words not
punctuation, but I'd appreciate an Emoticon Specific Language :)
[1] I mean #eval, Class#new, Module#new,define_method etc.. sorry, can't
think of a better name :)