Larry Wall wrote:
On Wed, Apr 01, 2009 at 08:40:12AM -0700, Dave Whipp wrote:
That said, the semantics of a chained relop really should work correctly
for this. If you only reference a junction once in an expression, then
it should behave as such: {a<b<c} !=== {a<b && b<c}.
Yes, that is the intent. I consider a chained "1 < $x < 2" to be a
single function from the standpoint of autothreading, something like
chained(1, &infix:«<», $x, &infix:«<», 2);
and the semantics would fall out of that naturally, more or less.
Something similar could also work for the blocks of conditionals
if we were to treat the conditional as a function that autothreads
consistently over both its condition and its blocks; this implies the
junction autothreader must be given enough access to the scope of the
block in question to temporarily override the value of $x within the
block to its autothreaded value somehow. The tricky bit is that
autothreading is setting up extra scopes around variant captures
without explicit blocks. That alone is reason enough to keep
the mechanism all internal.
Do I understand correctly from this that
my $x = 1|5; say ?(2 < $x < $4) ; # False
my $x = 1|3|5; say ?(2 < $x < $4); # True
If so, then the current implementation of rakudo is generating an error,
viz.,
$ perl6
> my $x=1|5; say ?( 2 < $x < 4)
1
May be something extra needs to be added to the specs?
If we do give access to universe of values the junction is interested
in, it should probably just be via a coercion to Set.
This would give the necessary extra syntax to ensure that the programmer
knows what s/he is doing. It means that junctions could be threshed and
sieved when desired.
There would have
to be some caveats about using that as the universe of values, however,
since none() junctions define a set outside of the eigenstates.
Interesting. Do I understand this correctly: If the junction is finite,
then none() defines an infinite set, and vice versa.
But then if perl6 is lazy, an infinite set would also be possible????
With access being lazily evaluated. Just as 0 .. inf is lazily evaluated?
For that reason I'd still prefer people to track their universe of
values outside the junctions rather than rely on junctions for that.
And of course, a Set in list context is its members, so any(%set) isn't
a problem going the other direction.
Larry