Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion BUILD and other submethods
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
 
Larry Wall  
View profile  
 More options May 16 2005, 11:48 am
Newsgroups: perl.perl6.language
From: la...@wall.org (Larry Wall)
Date: Mon, 16 May 2005 08:48:29 -0700
Local: Mon, May 16 2005 11:48 am
Subject: Re: BUILD and other submethods
On Mon, May 16, 2005 at 02:59:11PM +0000, Ingo Blechschmidt wrote:

: Hi,
:  
:   class Foo {
:     submethod BUILD() {
:       say 42;
:     }
:   }
:  
:   class Bar is Foo {
:     submethod BUILD() {
:       say 23;
:     }
:   }
:  
:   my Bar $bar .= new;
:  
: I suppose this will output:
:   42
:   23
:  
: S12 says that "submethod[s] [are] called only when a method call is
: dispatched directly to the current class", but the default implementation of
: "new" (as given by Object), calls BUILDALL, which in turn calls all BUILDs, so
: I think both BUILDs are executed. Are they?

Yes.

: S12 says that "[s]ubmethods are for declaring infrastructural methods that
: shouldn't be inherited by subclasses". I read this "shouldn't be inherited" as
: that a submethod definition of the same name in a subclass does not
: overwrite/substitute the definition of the parent class. Correct?

Correct.

:   class A      { submethod blarb() { say 42 } }
:   class B is A { submethod blarb() { say 23 } }
:   B.new.blarb;
:  
: Does this only output "23"? (I think so, as I don't call A::blarb explicitly.
: If I wanted to call A's blarb, I'd have to say "B.new.A::blarb", correct?)

Yes.

Larry


    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.

Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google