Re: Am I suppose to be able to change a variable's type on the fly?

2017-03-28 Thread Brandon Allbery
On Tue, Mar 28, 2017 at 3:09 AM, Francesco Rivetti wrote: > you don't change the type of a variable. instead you use a type which is > "broader" and accept any object type. This; and if you didn't specify a type, the type is Any. Which is not quite the root of the class/type

Re: Am I suppose to be able to change a variable's type on the fly?

2017-03-28 Thread Francesco Rivetti
On 22. mars 2017 06:59, ToddAndMargo wrote: So, unless I specifically declare a variable as a particular type, I can change its "type" on the fly. you don't change the type of a variable. instead you use a type which is "broader" and accept any object type. e.g.: you can assign 123 to an

Re: Am I suppose to be able to change a variable's type on the fly?

2017-03-22 Thread Richard Hainsworth
I think the strict answer to 'Is it correct?' is 'No'. The point being that 'my $x' gives $x type 'Any'. But practically, having type Any allows for $x to be assigned any value, be it Str, Int etc. So 'practically' the answer to 'Is it correct?' is 'Yes'. On Wednesday, March 22, 2017 02:07

Re: Am I suppose to be able to change a variable's type on the fly?

2017-03-22 Thread ToddAndMargo
> On Wed, Mar 22, 2017 at 12:59 AM, ToddAndMargo wrote: >> Hi All, >> >> Yes, I know, Perl is "lexiconical". >> >> $ perl6 -e 'my $x="abc"; $x=1E23; print "$x\n";' >> 1e+23 >> >> $ perl6 -e 'my Str $x="abc"; $x=1E23; print "$x\n";' >> Type check failed in assignment to

Re: Am I suppose to be able to change a variable's type on the fly?

2017-03-22 Thread Brad Gilbert
The default type constraint is Mu, with a default of Any (everything is of type Mu, and most are of type Any) You shouldn't be able to change the type constraint of a scalar container (used for rw variables) Changing the type of a value, of course makes no sense. (a Str is always a Str, even

Am I suppose to be able to change a variable's type on the fly?

2017-03-21 Thread ToddAndMargo
Hi All, Yes, I know, Perl is "lexiconical". $ perl6 -e 'my $x="abc"; $x=1E23; print "$x\n";' 1e+23 $ perl6 -e 'my Str $x="abc"; $x=1E23; print "$x\n";' Type check failed in assignment to $x; expected Str but got Num (1e+23) in block at -e line 1 So, unless I specifically declare a variable