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 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;
> }
>
> method showMyConst () {
> print $!myConst;
> }
> }
>
> But I'm getting the followinf error message: "Twigil-Variable constants
> not yet implemented. Sorry."
>
> The only place in the docs where I have found any reference to constants
> is in here: https://doc.perl6.org/language/variables#The_%3F_Twigil
> But it's not what I am looking for :/
>
> So my questions are:
> Is the syntax right and the thing isn't implemented yet?
> Is the syntax (or the full concept) wrong?
> Do I have and old interpreter (This is perl6 version 2015.02 built on
> MoarVM version 2015.02)?
>
> Thanks to all.
>
> Kind Regards,
> Emiliano
>


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;
}

method showMyConst () {
print $!myConst;
}
}

But I'm getting the followinf error message: "Twigil-Variable constants not yet 
implemented. Sorry."

The only place in the docs where I have found any reference to constants is in 
here: https://doc.perl6.org/language/variables#The_%3F_Twigil
But it's not what I am looking for :/

So my questions are:
Is the syntax right and the thing isn't implemented yet?
Is the syntax (or the full concept) wrong?
Do I have and old interpreter (This is perl6 version 2015.02 built on MoarVM 
version 2015.02)?

Thanks to all.

Kind Regards,
Emiliano