RE: Constants as members of a class

2015-12-18 Thread TS xx
Thanks Liz, I will stick with the method aproach. Regards, Emiliano > Subject: Re: Constants as members of a class > From: l...@dijkmat.nl > Date: Fri, 18 Dec 2015 23:49:53 +0100 > To: perl6-us...@perl.org > > > On 18 Dec 2015, at 23:37, TS xx wrote: > > > &

Re: Constants as members of a class

2015-12-18 Thread Elizabeth Mattijsen
> On 18 Dec 2015, at 23:37, TS xx wrote: > > Hi Liz, thanks for your reply. > > Can I call the method from static context? > I mean: MyClass.FOO In general, yes: class A { method FOO { 42 } # note the method doesn’t reference any attributes } say A.FOO; say A.new.FOO; # also works on in

RE: Constants as members of a class

2015-12-18 Thread TS xx
Hi Moritz, I need a constant static field in the class. I think the method aproach will do it. Thanks & Regards, Emiliano > Date: Fri, 18 Dec 2015 13:29:44 +0100 > From: mor...@faui2k3.org > To: perl6-us...@perl.org > Subject: Re: Constants as members of a class > > Hi,

RE: Constants as members of a class

2015-12-18 Thread TS xx
Hi Liz, thanks for your reply. Can I call the method from static context? I mean: MyClass.FOO > Subject: Re: Constants as members of a class > From: l...@dijkmat.nl > Date: Fri, 18 Dec 2015 10:23:11 +0100 > To: perl6-us...@perl.org > > > > On 18 Dec 2015

RE: Constants as members of a class

2015-12-18 Thread TS xx
Thanks anyway The new method is there just to state the example. Date: Thu, 17 Dec 2015 22:58:32 -0500 Subject: Re: Constants as members of a class From: awwa...@thelackthereof.org To: maringa...@hotmail.com CC: perl6-us...@perl.org Two things jump out at me. One is that I think you don't

Re: Constants as members of a class

2015-12-18 Thread Moritz Lenz
Hi, On 12/18/2015 03:46 AM, TS xx wrote: > Hello dear perl6 users, > > I was in the need of declaring a member variable as a constant integer. I don't understand this. If it's a constant, why does it need to be member at all? A member is per-instance storage, which seems to be a waste for a cons

Re: Constants as members of a class

2015-12-18 Thread Elizabeth Mattijsen
> On 18 Dec 2015, at 03:46, TS xx wrote: > > Hello dear perl6 users, > > I was in the need of declaring a member variable as a constant integer. After > many syntax tryouts I came to this one: > > class MyClass { > has int $.myConst; > > method new () { > return self.bless();

Re: Constants as members of a class

2015-12-17 Thread Darren Duncan
Since all you want is a constant, try declaring a submethod that has no arguments and returns the value, instead, its the same thing. -- Darren Duncan On 2015-12-17 6:46 PM, TS xx wrote: Hello dear perl6 users, I was in the need of declaring a member variable as a constant integer. After many

Re: Constants as members of a class

2015-12-17 Thread Brock Wilcox
Two things jump out at me. One is that I think you don't need that "new" method. Second -- yes, this is a very old interpreter. I unfortunately don't know about the twigil variable constant things. --Brock On Thu, Dec 17, 2015 at 9:46 PM, TS xx wrote: > Hello dear perl6 users, > > I was in the

Constants as members of a class

2015-12-17 Thread TS xx
Hello dear perl6 users, I was in the need of declaring a member variable as a constant integer. After many syntax tryouts I came to this one: class MyClass { has int $.myConst; method new () { return self.bless(); } submethod BUILD () { constant $!myConst = 1;