TSa Thomas.Sandlass-at-
This hinges on the details how binding works. If it is pure
name lookup then you can bind only variables of equal type.
But $Larry has the idea of $x1 and $x2 being different views
of the same underlying item. E.g.
That's not at all the same kind of thing as briefly described under what
static typing is all about and what binding means. It looks like this
feature would be more like a "tie" where multiple different variables
write back to the same original.
I'm not convinced that needs to be in the core language. It can be done
by programming appropriate container types, such as an aliased "item".
Can you give a pointer to where this was discussed?
--John
$x2 = " 2.010 ";
my Num $x3 := $x2;
say "x1 = ($1); x2 = ($2); x3 = ($x3)";
prints "x1 = ( 2.010 ); x2 = (2); x3 = (2.01)". That is
the chars of the original string are preserved in the Int|Str
view but lost in the Num or Int view. The latter is also
flooring away the fractional part. Some of the consequences
are that
$x1 ne $x2
$x1 != $x2
$x1 == $x3
but of course
$x1 =:= $x2 =:= $x3
but note that after
$x1 = 42;
we now have
$x1 eq $x2
$x1 == $x2
$x1 == $x3
The Int constraint of $x2 means of course that $x2 = 'xx' is
an error, but $x1 = 'xx' is legal and *indistinguishable*
from $x1 = 0 for $x2.
my Int $x3 := $x1 :defer; # OK, fetches checked at run-time
my Int|Str $y3 := y1 :defer; # OK, stores checked at run-time
my Int $x4 := $x1 :coerce; # fails at run time because actual
# container type still wrong
my Int $x5 := $y2 :coerce; # type check agrees at run time.
# (The :coerce and :defer adverbs to := is proposed)
With the view paradigm these adverbs are obsolete I guess.
Regards, TSa.