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 () { >

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

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-users@perl.org > > > On 18 Dec 2015, at 23:37, TS xx <maringa...@hotmail.com

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-users@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-users@perl.org Two things jump out at me. One is that I think you don't need

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

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