Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
New form of 'setattribute' fails when there are multiple inheritance levels
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
  3 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
 
Roger Browne  
View profile  
 More options Jun 28 2005, 10:32 am
Newsgroups: perl.perl6.internals
From: parrotbug-follo...@parrotcode.org (Roger Browne)
Date: Tue, 28 Jun 2005 07:32:02 -0700
Local: Tues, Jun 28 2005 10:32 am
Subject: [perl #36411] New form of 'setattribute' fails when there are multiple inheritance levels

# New Ticket Created by  Roger Browne
# Please include the string:  [perl #36411]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=36411 >

The following PIR (attached as "script.pir", and also included here)
fails under Parrot 0.2.1 (Fedora Core 3, Intel x86):

.sub main @MAIN
   $P1 = newclass "PARENT_1"
   addattribute $P1, "foo"                #1
   $P2 = subclass $P1, "PARENT_2"
   addattribute $P2, "foo"                #2
   $P3 = subclass $P2, "CHILD"
   addattribute $P3, "bar"

   $P0 = new "CHILD"

   $P97 = new .String
   set $P97, "Hello from attribute foo"
   setattribute $P0, "foo", $P97          #3

   $P98 = new .String
   set $P98, "Hello from attribute bar"
   setattribute $P0, "bar", $P98          #4

   $P99 = getattribute $P0, "foo"         #5
   print $P99
   print "\n"
   end
.end

This prints "Hello from attribute bar" when it should print "Hello from
attribute foo".

The bug disappears if line #4 is commented out, suggesting that
"setattribute foo" (line #3) and "setattribute bar" (line #4) are both
storing into the same slot that is retrieved by "getattribute foo".

The bug also disappears if either line #1 or line #2 is commented out,
suggesting that this bug is exposed by multiple layers of inheritance.

Here's the inheritance hierarchy:

   PARENT_1  # adds attribute 'foo'
      ^
      |
   PARENT_2  # adds attribute 'foo', hiding the inherited one
      ^
      |
    CHILD    # adds attribute 'bar'

Regards,
Roger Browne

[ script.pir < 1K ]
.sub main @MAIN
   $P1 = newclass "PARENT_1"
   addattribute $P1, "foo"                #1
   $P2 = subclass $P1, "PARENT_2"
   addattribute $P2, "foo"                #2
   $P3 = subclass $P2, "CHILD"
   addattribute $P3, "bar"

   $P0 = new "CHILD"

   $P97 = new .String
   set $P97, "Hello from attribute foo"
   setattribute $P0, "foo", $P97          #3

   $P98 = new .String
   set $P98, "Hello from attribute bar"
   setattribute $P0, "bar", $P98          #4

   $P99 = getattribute $P0, "foo"         #5
   print $P99
   print "\n"
   end
.end


 
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 Jun 29 2005, 6:03 am
Newsgroups: perl.perl6.internals
From: l...@toetsch.at (Leopold Toetsch)
Date: Wed, 29 Jun 2005 12:03:14 +0200
Local: Wed, Jun 29 2005 6:03 am
Subject: Re: [perl #36411] New form of 'setattribute' fails when there are multiple inheritance levels
Roger Browne (via RT) wrote:

> Here's the inheritance hierarchy:

>    PARENT_1  # adds attribute 'foo'
>       ^
>       |
>    PARENT_2  # adds attribute 'foo', hiding the inherited one
>       ^
>       |
>     CHILD    # adds attribute 'bar'

The first question is of course:

a) should we fully hide PARENT_1's "foo"
b) or should the attribute still be accessible as "PARENT_1\0foo"

or: how many attributes has CHILD?

leo


 
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.
Roger Browne  
View profile  
 More options Jun 29 2005, 6:36 am
Newsgroups: perl.perl6.internals
From: ro...@eiffel.demon.co.uk (Roger Browne)
Date: Wed, 29 Jun 2005 11:36:46 +0100
Local: Wed, Jun 29 2005 6:36 am
Subject: Re: [perl #36411] New form of 'setattribute' fails when there are multiple inheritance levels
On Wed, 2005-06-29 at 10:01 +0000, Leopold Toetsch via RT wrote:

> >    PARENT_1  # adds attribute 'foo'
> >       ^
> >       |
> >    PARENT_2  # adds attribute 'foo', hiding the inherited one
> >       ^
> >       |
> >     CHILD    # adds attribute 'bar'

> The first question is of course:

> a) should we fully hide PARENT_1's "foo"
> b) or should the attribute still be accessible as "PARENT_1\0foo"

> or: how many attributes has CHILD?

We also need to ask how many attributes CHILD has in the case of
multiple inheritance (where PARENT_1 and PARENT_2 both have attribute
'foo'):

   PARENT_1   PARENT_2
        ^       ^
         \     /
          CHILD

I can live with either answer (from the point of view of implementing
the Amber compiler).

Regards,
Roger Browne


 
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 »