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
Calling Super Methods
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
  4 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
 
Matt Diephouse  
View profile  
 More options Jul 22 2005, 7:32 pm
Newsgroups: perl.perl6.internals
From: mdd...@gmail.com (Matt Diephouse)
Date: Fri, 22 Jul 2005 19:32:17 -0400
Local: Fri, Jul 22 2005 7:32 pm
Subject: Calling Super Methods
There's currently no way to call a superclass' method. I've just run
into this and leo suggested I sent a note to the list.

Here's what I want to do:

I have a ParrotClass (a class defined in PIR) that is derived from the
String class. I want to override it's set_string_native method to do
some processing before I store the value. My first attempt was this:

    .sub __set_string_native method
      .param string value
      self = value
      print "assign\n"
    .end

Of course, that doesn't work: `self = value` just calls the method
again and you quickly hit the recursion limit. While I probably won't
be able to use the = syntax, I should be able to call the parent's
method (since I can't actually set the string value myself like I can
in PMC-land).

Something like this ought to work:

     .sub __set_string_native method
      .param string value
      self.SUPER::__set_string_native(value)
      print "assign\n"
    .end

I don't really care how it looks really, as long as it's possible. Any
thoughts? It'd be nice to get this specced so that it can be
implemented.

Thanks.

--
matt diephouse
http://matt.diephouse.com


 
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 Jul 23 2005, 7:58 am
Newsgroups: perl.perl6.internals
From: l...@toetsch.at (Leopold Toetsch)
Date: Sat, 23 Jul 2005 13:58:26 +0200
Local: Sat, Jul 23 2005 7:58 am
Subject: Re: Calling Super Methods

Matt Diephouse wrote:
> There's currently no way to call a superclass' method. I've just run
> into this and leo suggested I sent a note to the list.

> Here's what I want to do:

> I have a ParrotClass (a class defined in PIR) that is derived from the
> String class. I want to override it's set_string_native method to do
> some processing before I store the value. My first attempt was this:

>     .sub __set_string_native method
>       .param string value
>       self = value
>       print "assign\n"
>     .end

While we haven't something like:

>       self.SUPER::__set_string_native(value)

... it's still possible to call super for some methods like the
__set_string_native, by extracting the first attribute:

.sub __set_string_native method
    .param string s
    $I0 = classoffset self, "MyClass"
    $P0 = getattribute self, $I0
    $P0 = s
.end

see also t/pmc/object-meths_30.pir (r8674)

The question ramains of course, why you should do that, as the inherited
method just does the same, that is - just don't declare
__set_string_native, *if* there isn't any difference in implementation.

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.
Klaas-Jan Stol  
View profile  
 More options Jul 23 2005, 11:46 am
Newsgroups: perl.perl6.internals
From: vander...@home.nl (Klaas-Jan Stol)
Date: Sat, 23 Jul 2005 17:46:25 +0200
Local: Sat, Jul 23 2005 11:46 am
Subject: Re: Calling Super Methods

I've been in situations that you would want to call the superclass'
constructor from the child's constructor, this is handy in situations
that you want to add some extra things to the constructor, and you don't
want to duplicate the code. So, in my opinion it would be handy.
A somewhat related point to this, as well as related to an earlier
question of mine wrt implementing PMCs in PIR; is it possible to access
the internal datastructure of the PMC in PIR? So, for example, if you
would want to set/get the integer value of a PMC in PIR, how would you
do that? (or will there be supporting syntax for that?)

klaas-jan


 
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 Jul 23 2005, 3:19 pm
Newsgroups: perl.perl6.internals
From: l...@toetsch.at (Leopold Toetsch)
Date: Sat, 23 Jul 2005 21:19:49 +0200
Local: Sat, Jul 23 2005 3:19 pm
Subject: Re: Calling Super Methods

On Jul 23, 2005, at 17:46, Klaas-Jan Stol wrote:

> I've been in situations that you would want to call the superclass'
> constructor from the child's constructor, this is handy in situations
> that you want to add some extra things to the constructor, and you
> don't want to duplicate the code. So, in my opinion it would be handy.

Yep

> A somewhat related point to this, as well as related to an earlier
> question of mine wrt implementing PMCs in PIR; is it possible to
> access the internal datastructure of the PMC in PIR? So, for example,
> if you would want to set/get the integer value of a PMC in PIR, how
> would you do that? (or will there be supporting syntax for that?)

Exactly as I"ve shown above with the string access. A ParrotObject
subclassed from a PMC has an instance of that PMC as it's first
attribute - named '__value'.
If the object is created from a class w/o a PMC parent (i.e. with the
newclass opcode) you have to implement all the vtables in PIR and store
the information in some attribute, you have to create too.

> klaas-jan

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.
End of messages
« Back to Discussions « Newer topic     Older topic »