develooper Front page | perl.perl6.compiler | Postings from May 2012

Fwd: [perl #112676] SUPER does not seem to work

From:
phiroc
Date:
May 3, 2012 01:46
Subject:
Fwd: [perl #112676] SUPER does not seem to work
Message ID:
1931729326.211455766.1335794832608.JavaMail.root@zimbra65-e11.priv.proxad.net

Hi,

I have tried most of the examples in the Wrap Chapter in S6, and I kept gettting a

"Not enough positional parameters passed; got 0 but expected 1" error message.

Try the following code:

sub thermo ($t) { say "t is $t in thermo"; }  
&thermo.wrap( { callwith( ($^t-32)/1.8 ) } );
say &thermo(12);

Furthermore, "temp" is treated as a sub (!) ("could not find sub '&temp'").

For instance,

sub thermo ($t) { say "t is $t in thermo"; }  
#&thermo.wrap( { callwith( ($^t-32)/1.8 ) } ); 
temp &thermo.wrap( { callwith($^t + 273.16) } );
say &thermo(12);

 
Regards,

Philippe



----- Mail transféré -----
De: phiroc@free.fr
À: perl6-bugs-followup@perl.org
Envoyé: Lundi 30 Avril 2012 11:34:51
Objet: Re: [perl #112676] SUPER does not seem to work

Hi,

the S6 and S12 docs are not very clear on how to use nextsame to call super methods, etc.

Could you please provide examples of how to call the superclass's constructor?
Furthermore, I can't get the below code to work.

Many thanks.

Best regards,

Philippe

-------------
class cell {
	has Int $.contents = 0;
}
class reCell is cell {
	has Int $.backup = 0;
	method new(Int $contents) {
		backup => $contents;
		contents => $contents;
	}
}

my $reCell = reCell.new(contents => 2);

print $reCell.contents;




----- Mail original -----
De: "Moritz Lenz via RT" <perl6-bugs-followup@perl.org>
À: phiroc@free.fr
Envoyé: Lundi 30 Avril 2012 09:44:48
Objet: [perl #112676] SUPER does not seem to work 

There is no SUPER. And the WALK syntax you are using is purely
imaginary, and not backed by the spec. See S06 for nextsame and friends
about how to do the stuff you want to do.



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About