From: Ron Jeffries Date: 2002-02-25T00:42:24+09:00 Subject: Re: duplicate method name On Sun, 24 Feb 2002 15:02:15 GMT, ts wrote: >>>>>> "R" == Ron Jeffries writes: > >R> And the fix is not to space after the second meth. What else could .meth >R> mean at that point? What mistake is it warning me about? > > .meth at this point is interpreted as a method call, this is why ruby > don't expect space before `(' I must be missing something, because I don't get it. What could .meth possibly be other than a method call? What could the stuff in parens possibly be other than the parameters? > > It's best to see it with 1.7.2 because there is a small modification > >pigeon% cat b.rb >#!./ruby -w >class Object > def meth(arg) > return arg*2 > end >end > >meth (1 or 2) >pigeon% > >pigeon% b.rb >/b.rb:8: warning: meth (...) interpreted as grouped expression I find this message even less helpful than the previous one. Is this a different interpretation of the same code (really bad idea IMO) or just a different message? >pigeon% > >pigeon% cat b.rb >#!./ruby -w >class Object > def meth(arg) > return arg*2 > end >end > >meth(1 or 2) >pigeon% >pigeon% b.rb >/b.rb:8: parse error >meth(1 or 2) > ^ >/b.rb:8: warning: useless use of a literal in void context And what is this trying to tell me? What's the point of "void context"? I've read a lot of compiler diagnostics in my life, and these aren't among the best. I'll be happy to read stuff that I've missed if someone wants to point me at it. Thanks, Ronald E Jeffries http://www.XProgramming.com http://www.objectmentor.com I'm giving the best advice I have. You get to decide whether it's true for you.