Dave Whipp wrote:
I'm thinking that the solution to this issue may be a little more radical than to-date: don't permit junctions to be stored in $ variables! Instead, require junctions to use a twiggle, to alert the reader that the surprises may be lurking.

my $x = 1|2; #error
my $|x = 1|2; # ok

Then you just need to invent some syntax to say that collapse is (or perhaps isn't) desired:

if [[ $|x > 1 ]] { say "$|x collapsed" }

The most important thing that this does is that it leaves open the option to allow "$" variables to hold junctions in some future version of Perl, without that future version being constrained by legacy semantics.


I'd second the twigil idea. Reason: I'd -really- like perl6 to be compilable into an efficient machine code without a JIT magic that we can currently only handwave about.

For that, I'd propose a rule of a thumb: ints are ints. Of course, floats and other unboxed types should also be just plain unboxed types, but I'd like the rule of a thumb to be short and to the point.

So,

int $x = 1|2;

should be an error.

Also,

int $x = 1 but "not really a number";

should also be an error or at least a warning that mixin stripping and unboxing took place. If you want polymorphic here, use Ints. That'd also mean that

my @x of int;

can be implemented as a homogenous int vector, meaning -really- efficient and manipulable through the kind of code that modern CPUs are really good at (since as soon as you know you won't be lazy, you only need to be polymorphic about asking for the beginning of the in-memory buffer that can be manipulated directly. Even if that buffer doesn't contain all the elements, you can refill it as needed, and that could still be fast as long as the other side of the partially-lazy barrier also speaks int). Also, as far as I'm aware, there is no tracing VM that can create a homogenous arrays for you if you can't already do them.

From the above, the need for twigils in junctions should be apparent.

   Miro

Reply via email to