newclass P1, "Foo"
addattribute P1, "foo_i"
addattribute P1, "foo_j"
set I1, P1
print I1
and the code will print '2'. Will this be part of the new API, or is it
simply a relic of the previous implementation.
Similarly, calling get_integer_keyed_str with a fully-qualified attribute
name returns the attribute offsets, meaning that this:
newclass P1, "Foo"
addattribute P1, "foo_i"
addattribute P1, "foo_j"
set I2, P1["Foo\x00foo_j"]
print I2
prints '1' -- is this part of the API or not?
Finally, a number of the current tests seem to rely on being able to
set and get attribute values with the syntax:
set P2["Foo\x00i"], 10
set P3["Foo\x00i"], 20
set I2, P2["Foo\x00i"]
set I3, P3["Foo\x00i"]
(where P2, P3 are objects of class Foo, and Foo has an attribute i).
Is this part of the API?
Simon
Relic.
> Similarly, calling get_integer_keyed_str with a fully-qualified attribute
> name returns the attribute offsets, meaning that this:
>
> newclass P1, "Foo"
> addattribute P1, "foo_i"
> addattribute P1, "foo_j"
> set I2, P1["Foo\x00foo_j"]
> print I2
>
> prints '1' -- is this part of the API or not?
Relic.
> Finally, a number of the current tests seem to rely on being able to
> set and get attribute values with the syntax:
>
> set P2["Foo\x00i"], 10
> set P3["Foo\x00i"], 20
> set I2, P2["Foo\x00i"]
> set I3, P3["Foo\x00i"]
>
> (where P2, P3 are objects of class Foo, and Foo has an attribute i).
> Is this part of the API?
Relic.
In all these cases the object will ultimately do a method lookup to
see if it has a method in place to do the operation, so you can
substitute an object for any other sort of PMC. Attribute access
should be only through the attribute API.
--
Dan
--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
d...@sidhe.org have teddy bears and even
teddy bears get drunk
Should asking for a non-existant attribute cause Parrot to throw an
exception. Currently, it doesn't seem to be able to make up its mind
-- this:
newclass P1, "Foo"
find_type I0, "Foo"
new P2, I0
getattribute P3, P2, -2
getattribute P3, P2, -1
getattribute P3, P2, 0
getattribute P3, P2, 1
end
completes silently, but if we ask for an attribute with an offset >= 2
or <= -3, we get an "Array index out of bounds!" exception. Which is the
correct behaviour?
(Incidentally, I get the same behaviour with setattribute).
Simon
That was a problem with array wraparound -- I put in checking code
for this, FWIW.