develooper Front page | perl.perl6.language | Postings from February 2005

Junctive puzzles.

Thread Previous | Thread Next
From:
Autrijus Tang
Date:
February 5, 2005 04:33
Subject:
Junctive puzzles.
Message ID:
20050205123325.GA68505@aut.dyndns.org
(I've just finished the pretty printing part in Pugs, so I'll use actual
command line transcripts below.  The leading "?" does not denote boolean
context -- it's just telling pugs to do a big-step evaluation.  Also,
boolean literals are written in their Scheme forms.)

In S06, the meaning of chaining comparison operators is defined as a
derived form:

    (a < b < c)		==>	    (a < b) and (b < c)

With the note that "b" must be evaluated at most once.  However, if
taken literally, it gives this rather weird result:

    pugs> ? 2 < (0 | 3) < 4
    (#t|#t)

My intuition is that it should be equivalent to this:

    pugs> ? (2 < 0 < 4) | (2 < 3 < 4)
    (#f|#t)

That is, the autothreading should operate on the whole comparison chain,
treating it as a large variadic function with short-circuiting semantics.
Is this perhaps "saner" than the blind rewrite suggested in the spec?

Also, consider this:

    pugs> ? 1|2 => 3|4
    (((1 => 3)|(1 => 4))|((2 => 3)|(2 => 4)))

Since junctions are documented to only "flatten" on boolean context,
here the pair-building arrow has been autothreaded.  Is it the intended
semantic?  What about the list-building semicolon?

Thanks,
/Autrijus/


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About