Re: new method question

2008-08-22 Thread John M. Dlugosz
Moritz Lenz moritz-at-casella.verplant.org |Perl 6| wrote: Attributes need to have a twigil, so it would be has $.name The syntax has $name; with no twigil is legal according to S12. Perhaps the original poster (Xiao Yafeng) might like to read

Re: whats wrong with this code?

2008-08-22 Thread Larry Wall
On Fri, Aug 22, 2008 at 05:30:19PM -0500, Andy Colson wrote: > Moritz Lenz wrote: > > The recommended way to write such a sub is > > > > sub xsum([EMAIL PROTECTED]) { ... } > > xsum(|@x); > > Ahh, but, if I already had a list, would that flatten and then rebuild > the list, correct? (and would, e

Re: whats wrong with this code?

2008-08-22 Thread Moritz Lenz
Patrick R. Michaud wrote: > On Fri, Aug 22, 2008 at 04:34:04PM -0500, Andy Colson wrote: >> sub xsum (@list) >> { >> my $i = 0; >> print "summing: "; >> for @list >> { >> $i += $_; >> print $_,","; >> } >> say " = $i";

Re: whats wrong with this code?

2008-08-22 Thread Patrick R. Michaud
On Fri, Aug 22, 2008 at 04:34:04PM -0500, Andy Colson wrote: > sub xsum (@list) > { > my $i = 0; > print "summing: "; > for @list > { > $i += $_; > print $_,","; > } > say " = $i"; > return $i; > } > say "sum =

Re: whats wrong with this code?

2008-08-22 Thread Andy Colson
Moritz Lenz wrote: Hi Andy, you seem to have discovered a whole bunch of bugs at once :/ Andy Colson wrote: Hi List -- I'v started playing around with perl 6, and I am having problems with this example: use v6; sub xsum (@list) { my $i = 0; print "summing: "; f

Re: whats wrong with this code?

2008-08-22 Thread Moritz Lenz
Hi Andy, you seem to have discovered a whole bunch of bugs at once :/ Andy Colson wrote: > Hi List -- > > I'v started playing around with perl 6, and I am having problems with > this example: > > use v6; > > sub xsum (@list) > { > my $i = 0; > print "summing: "; >

Re: new method question

2008-08-22 Thread Moritz Lenz
Xiao Yafeng wrote: > There are no barewords in Perl 6, but it seems new method is an exception: > > class Dog { > > has $name; Attributes need to have a twigil, so it would be has $.name > method bark () { > say $name; > } > } > my $p = Dog.new(

whats wrong with this code?

2008-08-22 Thread Andy Colson
Hi List -- I'v started playing around with perl 6, and I am having problems with this example: use v6; sub xsum (@list) { my $i = 0; print "summing: "; for @list { $i += $_; print $_,","; } say " = $i"; re

new method question

2008-08-22 Thread Xiao Yafeng
There are no barewords in Perl 6, but it seems new method is an exception: class Dog { has $name; method bark () { say $name; } } my $p = Dog.new($name => 'boo'); $p.bark;#error! my $p = Dog.new( name => 'boo');