--bcaec547c8e9ba789904abf3caa4 Content-Type: text/plain; charset=ISO-8859-1 On Fri, Sep 2, 2011 at 12:54 AM, Justin Collins <justincollins / ucla.edu>wrote: > On 09/01/2011 06:57 PM, Michael Edgar wrote: > >> On Sep 1, 2011, at 9:37 PM, Justin Collins wrote: >> >> For what I use it for, I don't care about the exact syntax used when they >>> mean the same thing, and the fewer node types I need to check for, the >>> better. >>> >> I suspect this is actually only true at the margins, which is why parse >> trees are valuable and why I argue the corners RubyParser cuts are arbitrary >> and silly. >> >> Would you prefer that RubyParser turn "@foo ar" into a call to >> "instance_variable_set"? >> > > Kind of... :) But "instance_variable_set" might have a different meaning > than "@foo ar". Whereas, as far as I know, "a[]" and "a.[]()" will always > be the same. > > > Or "class A< B; end" into a series of conditions, constant lookups, >> assignments, "Class.new(B)", and so on? >> > > I think this might be going in the other direction (but you may also be > correct). In "a[]" vs. "a.[]()", RubyParser makes it easier because I only > have to look for a call to "[]". How the call is represented in the actual > code is not important (to me!). If it were always valid to assume that the > above-mentioned conditions, lookups, etc., would mean the same as "class A < > B; end" then I (in my case!) would not mind if I just got back something > representing "class A < B; end". In other words, the reverse of what you are > suggesting. > > > Should "class<< foo; end" turn into "foo.singleton_class.class_**eval >> do.. end"? >> >> Michael Edgar >> adgar / carboni.ca >> http://carboni.ca/ >> > > Will they always mean exactly the same thing? There are very few cases I > can think of where two bits of Ruby code will _always_ be the same thing, > because you can override nearly anything. > > Here's another case: > > ruby-1.9.2-p290 :003 > RubyParser.new.parse "!a" >