HaloO,
Jonathan Lang wrote:
Rob Kinyon wrote:
To me, this implies that junctions don't have a complete definition.
Either they're ordered or they're not.
So, is there a number between 0 and 1? Shades between black and white?
When is a 360 degree turn not returning a system into its initial state?
What has a 720 degree turn to do with sign reversal, negation and
twisted arms? Anyone know the Eisenstein integers? Is 5 a prime complex
number? What is its quadratic residue?
(-1)**2 == -i**2 == +1
\
?-->0 # if <=>
/
i**2 == -1
------------------------------ mirror symmetry axis
j**2 == -1
\
!-->0 # unless <=>
/
(-1)**2 == -j**2 == +1
But note that *same* symmetrie is broken! Ever wondered why a mirror
changes left and right, but not up and down? And what has all that
to do with anagrams like 'OTTO' and 'TOOT' or with bits '.**.' and
'*..*'? Or the range operators ^..^ .^^.?
Conceptually the 0 has no sign unless you want it to be junctive ;)
if you rotate the above vector diagrams by 120 degrees endlessly
clockwise and counter clockwise you get
upper: ...,0, 1,-1,0,...
lower: ...,0,-1, 1,0,...
which when superimposed additively lets the infinity of the
lists nicely vanish. But not the same is not true if one is
shifted, the other squared and then subtracted, or some such.
The thing is you end up with the infinte list (...,!0,!0,...).
The net effect is the same as reading the list's string representations
in opposite directions. There is no dark side of the moon really!
Here's the same in another ascii picture:
i\+/+
-\+ +\- 2** -<=>+ **2 +/+ -/-
-/-\-i**2
center stage we find <=> which returns one(-1,0,+1) or rotations
thereof: one(0,+1,-1) or one(+1,-1,0). Or the odd permutations
one(0,-1,+1), one(-1,+1,0) and one(+1,0,-1). In other words three
pairs of ones that cancel each other if zipped additively. The only
thing we need is a neutral element to get a group. Let's take the
empty one() junction. But an empty any() would do as well. These
sort of represent no comparison at all and a comparison you don't
care to constrain any further! In the latter case an undef return
value is not unexpected, I hope.
This is how that looks in an example:
'foo' cmp 'bor'
--> <f o o> »cmp« <b o r> <--
--> (-1, +0, +1) | (+1, -0, -1) <--
The arrows indicate reading direction of the respective string.
In a optimised implementation the outer f/b and and r/o give
the invariant relative positions of one('foo','oof') and
one('bor','rob') in the order of strings in viewing direction.
At least that is the observable behaviour. Endianess of the
machine, representation of junctions and what not may differ
for concrete implementations of Perl6 :)
Note that
[?] (-1, +0, +1) »+« (+1, -0, -1)
--> [?] (0,0,0)
--> false
With (-++) and (+--) beeing dual Minkowski metrics.
Either I can put them in a <=
expression and it makes sense or I can't.
HiHi, this is a statement about the programmer's abilities...
not about Perl 6 the language!
If it makes sense, then that
implies that if $x <= $y is true, then $x > $y is false. Otherwise,
the definitions of <= and > have been violated.
I'll beg to differ. If you insist on that kind of restriction on
Junctions, they won't be able to serve their original (and primary)
purpose of aggragating comparison tests together. Remember:
if $x <= 1 & 5 {...}
is intended to be 'shorthand' for
if $x <= 1 && $x <= 5 {...}
I beg to differ, two err too. I mean potentially from both depending
on what they intented to say and how I understood them.
My point is that the junctive case sort of means:
if $x.all:{<=}(1,5) {...}
where :{<=} receives similar meta treatment as [<=] reduce would.
BTW, isn't bareword suffixing {<=} reserved for type theoretic
manipulations? I still regard the junctions as Code subtypes and
thus any{<=} and friends as parametric meta operation.
Therefore,
$x = 3;
if $x <= 1 & 5 {say 'smaller'}
if $x > 1 & 5 {say 'larger'}
should produce exactly the same output as
$x = 3;
if $x <= 1 && $x <= 5 {say 'smaller'}
This is slightly untrue. because if the junction contains two
identical values or an undef ordered object the < part is
essentially stripped away:
if $x <= 5 && $x <= 5 {say 'smaller'}
can be permuted into
if $x <= 5 && 5 > $x {say 'smaller'}
and optimized to
if $x == 5 {say 'smaller'}
if $x > 1 && $x > 5 {say 'larger'}
If it doesn't, then Junctions are useless and should be stricken from Perl 6.
And the definition of '>' is "greater than", not "not (less than or
equal to)". The latter is a fact derived from how numbers and letters
behave, not anything inherent in the comparison operator.
The complete group of comparison operators imposes the order on the
underlying uninterpreted set of data.
Just like
'<=' is "less than or equal to", as opposed to "not greater than".
Indeed I regard the gangs of 2*7 + 7 == 21 comparison operators
bound by a theory of GF(8) === GF(2**3), that is a Galois group
with 8 members.
Here are more (pretty|pitty) pictures:
{>=}----{>}
/ \ / \
/ \ / \
/ \ / \
{==}----{?}----{!=}
\ / \ /
\ / \ / {gt}---{ge}
\ / \ / / \ / \
{<=}----{<} / \ / \
/ \ / \
:( cmp --> {ne}----{~}----{eq} <-- pmc :)
\ / \ /
{>}-----{>=} \ / \ /
/ \ / \ \ / \ /
/ \ / \ {lt}---{le}
/ \ / \
{!=}----{!}----{==}
\ / \ /
\ / \ /
\ / \ /
{<}-----{<=}
I hope the two numeric ones on the left look like projected cubes
while the string gadget is a flat hexagon projected from stringfinity.
The generators of the theory instances are {if <=>}, {unless <=>} and
{cmp} respectively. BTW the latter could actually return one of the
three strings '<', '=' or '>' and numerifying as
+'=' == 75 == 60 + 15 == 60 + 7 + 8 == 2:111100 + 2:111 + 2:100
+'<' == 74 == 60 + 14 == 60 + 7 * 2 == 2:111100 + 2:111 * 2:010
+'>' == 76 == 60 + 16 == 60 + 2 * 8 == 2:111100 + 2:010 * 2:100
in the---at least to me---obvious way :)
You aren't violating the definitions of <= and > by failing to insist
that they be logical negations of each other; you're only violating
the common wisdom.
Well, and any optimizations that depend on Galois theory to hold ;)
--