From: Eric Mahurin Date: 2005-05-27T23:50:26+09:00 Subject: Re: will callable objects be more general in Ruby 1.9? --- Yukihiro Matsumoto wrote: > |In terms of compatibility, I assume you are referring to the > |fact that if you have a local variable f (callable or not), > f() > |will try to call it even if the method f exists (in 1.9). I > |like this new behavior (local variables always override), > but > |to preserve compatibility couldn't you just change the > |priority? - f() would prefer calling method f over calling > |local variable f. > > The priority idea is interesting. My two concerns are: > > * it might make it hard for humans to understand what code > does, by > introducing runtime ambiguity. > * I'm not sure if yacc allows that kind of priority > resolution. I would assume it would be workable because you already have to deal with priority between local variables and methods - "xyz" will prefer accessing local variable xyz over calling method "xyz". If this is still not wanted, another option would be to allow a block to follow the [] operator (and be associated with it). I think this is a much smaller change to the language. This way you could do something like this: f = {|*args,&block|...} f["hello","world"] {puts("bye")} which has the same conciseness as: f("hello","world") {puts("bye")} and allows "f" to be an arbitrary object expression. The main downside is that the [] is necessary so that you can't say: f {puts("bye")} __________________________________ Do you Yahoo!? Yahoo! Small Business - Try our new Resources site http://smallbusiness.yahoo.com/resources/