Google Groups Home
Help | Sign in
How to check an attribute's existence
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Cory Spencer  
View profile  
 More options Feb 24 2005, 2:05 pm
Newsgroups: perl.perl6.internals
From: cspen...@sprocket.org (Cory Spencer)
Date: Thu, 24 Feb 2005 12:05:59 -0700 (MST)
Local: Thurs, Feb 24 2005 2:05 pm
Subject: How to check an attribute's existence

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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leopold Toetsch  
View profile  
 More options Feb 25 2005, 2:52 am
Newsgroups: perl.perl6.internals
From: l...@toetsch.at (Leopold Toetsch)
Date: Fri, 25 Feb 2005 08:52:26 +0100
Local: Fri, Feb 25 2005 2:52 am
Subject: Re: How to check an attribute's existence

Cory Spencer <cspen...@sprocket.org> 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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google