develooper Front page | perl.perl6.language | Postings from June 2006

Re: ~~ with *

Thread Previous
Larry Wall
June 20, 2006 11:51
Re: ~~ with *
Message ID:
On Mon, Jun 19, 2006 at 08:51:24AM -0600, Eric wrote:
:   Just my two cents, but whenever i see "when True {...}" I expect $_
: to be true, so that i can do when True and when False.  And I if see
: when followed by a comparison i expect the when to be true when the
: comparison is true.  To me its kind of like, if you only have one
: operand then use the given subject, if you have two operands then they
: don't need a subject.  So the given $_ topic would fill in only in the
: cases where you needed a topic.  Of course that might not realy make
: since for given/when and its smart matching magic.  But then maybe we
: just don't want to be able to say "when $a == $b" and thats just
: invalid since it would be clearer written as an if.

After much mulling, I've I've left booleans in a priviledged state of
assuming {...} around themselves. (Wrapping in {...} is the generic
method of suppressing comparison to $_, though ? and true() also work
for that.)  You can always write

    given $boolean {
	when .true {...}
	when .not {...}

to mean the other thing.  Or horrors, maybe even just use an "if"...


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About