--- On Tue, 10/7/08, Klaas-Jan Stol via RT <[EMAIL PROTECTED]> wrote:
> > > Why should this be a PAST::Var node as opposed to > simply > > > using a > > > PAST::Op node with :pirop('getprop') > and/or > > > :pirop('setprop') ? > > > > > > Pm > > > > > > Why is this different than attribute access? > > > > Maybe, because an attribute access can be more complex, or > 'nested', if you > like. For instance, consider this pseudo code: > > foo.bar.baz = 1 > > From the top of my head, I would implement this as a > PAST::Var, of type > 'attribute', where the attribute is itself > represented by a PAST::Var node, > again of type 'attribute'. > > so: > PAST::Var (foo, PAST::Var(bar, baz)) > > (not sure if that notation makes any sense, but the first > operand is the > object to be indexed, the second is the key). > > A property on the other hand is simpler; it's just a > 'tag' on the object. > (or maybe it can be accessed in a similar way as > attributes, the example > above, ?) > Just a thought. > > kjs The same can be done with properties. If I understand correctly, the difference between properties and attributes is just that attributes apply to every instance of a class and properties can be assigned to every object independently. PDD15 says that Python attributes map to Parrot properties. So the same line in Python (well, Pynie :) foo.bar.baz = 1 would mean setprop(getprop(foo, 'bar'), 'baz', 1) or PAST::Bind( PAST::Var('baz', PAST::Var('bar', PAST::Var('foo'))), 1) I think using Bind like this would be much easier than having to figure out that the lvalue is a property access when compiling the assignment statement. (Or otherwise figuring out to use getprop). This is also similar to the way keyed operations work. (I mean: foo[0], foo['baz'] )