HaloO,
Luke Palmer wrote:
In fact, it might even bug me more. I'm a proponent of the idea that
one name (in a particular scope) is one concept. We don't overload +
to mean "concatenation", we don't overload << to mean "output", and we
don't overload > to mean "outside".
I agree. And have converted inside to be implemented by ~~ as
hinted by Juerd. But even with the previous idea 1..10 < -5
would have been false I guess:
1..10 < -5 === 1 < -5 < 10
=== 1 < -5 && -5 < 10 === false
Actually +(10..1) == -9 because the measure is always .max - .min
even if .max < .min! But the Range role might be applicable where
the strict ordering < and > don't. E.g. in the complex plane ranges
form rectangles or ring segments depending on the parametrisation
choosen. In the ifinitesimal (point)limit both coincide, of course!
Supposing you fixed those operators, I really think that this is a job
for a module. All the syntax and semantics you propose can be easily
implemented by a module, except for the basic definition of "..".
Which was the actual reason to post the idea in the first place.
Note that the proposed ,, and ;; nicely complement the other
list constructors. The infinite lazy list might actually be
written with pre- or postfix ,,, without running into the same
problem as ... which in my conception of .. as numeric nicely denotes
a Code that doesn't actually iterate a Num. Also the ^..^ forms
are much less important since we've got the unary ^ now. Character
doubling and trippling is actually a theme in Perl6 operator design.
Just compare @a[[;]0,1,2] to @a[0;;2] visually. Not to mention
the---at least to my eye---very strange @; slice vars. BTW, is @foo
automagically related to @;foo? S02 is actually very close to
@foo[1;;5] with its @foo[1;*;5] form. The fact that the [;] reduce
form as slice actually means [<==] makes things not easier.
Here is an idea to replace @;x just with a code var:
my &x;
&x <== %hash.keys.grep: {/^X/};
&x <== =<>;
&x <== 1,,,; # note the ,,,
&x <== gather { loop { take rand 100 } };
%hash{x} # nice usage of closure index
which to me looks much nicer and increases the importance of
the & sigil and code types! At the first invocation of <== the
Pipe is autovivified in &x and the second invocation adds to the
outer dimension of the List of Pipe. Note that I think that in
x <== 1,,4;
operator <== sees a :(Call of x) type as lhs. What semantic
that might have I don't now. But if that's not an error then perhaps
the former content is lost, an empty code ref is autovivified into &x
and given to <== as lhs. YMMV, though ;)
Actually evaluating a Pipe stored in a & var might just result
in unboxing the Pipe without changing the former content.
&x <== 1,,4;
&x <== x <== x <== x; # &x now is Pipe (1,,4;1,,4;1,,4)
Also I realized that the zip, each, roundrobin and cat functions
mentioned in S03 are somewhat redundant with proper typing.
What diffentiates
cat(@x;@y)
from
(@x,@y) #?
Or
for zip(@names; @codes) -> [$name, $zip] {...}
from
for (@names; @codes) -> [$name, $zip] {...} #?
And why is
for each(@names; @codes) -> $name, $zip {...}
not just
for (@names; @codes) -> $name, $zip {...} #?
Apart from beeing good documentation, of course.
Yet another thing I didn't mention so far is that I see , and ;
as corresponding to ~ for strings. So parts of the conclomerat of
roles for Num and List is replicated with a different syntactical
wrapper for Str. And user defined classes can hook into this at will
by means of role composition and operator overloading.
At a lower level all this is unified syntactically! But how much
the syntax there resembles the humanized forms of Perl6, I can only
guess. On the engine level the only thing that remains is MMD and
error handling.
Maybe you could make it your first Perl 6 module?
Uhh, let's see what I can do about that. Unfortunately
I'm lazy there... *$TSa :)
--