Is is possible to check to see whether an attribute exists on a given
object, or at least catch an exception if it doesn't? I've tried to set
up an exception handler, but Parrot exits without anything being caught.
A code snippet follows:
.sub _main
.local pmc class
.local int type
.local pmc foo
.local pmc val
# The Foo class only has a "bar" attribute.
newclass class, "Foo"
addattribute class, "bar"
# Create a Foo object
find_type type, "Foo"
new foo, type
push_eh EXCEPTION
# Try to access the invalid "baz" attribute.
getattribute val, foo, "baz"
end
EXCEPTION:
print "* caught an exception!\n"
end
.end
Cory Spencer <cspencer@no-spam> wrote:
> Is is possible to check to see whether an attribute exists on a given
> object, or at least catch an exception if it doesn't? I've tried to set
> up an exception handler, but Parrot exits without anything being caught.
Not yet. C<getattribute> throws currently an uncatchable internal
exception.
leo