Front page | perl.perl6.language |
Postings from June 2006
~~ with *
Thread Next
From:
Daniel Hulme
Date:
June 6, 2006 09:13
Subject:
~~ with *
Message ID:
20060606161126.GA22368@istic.org
I only vaguely recall the discussions a while back about what
smart-matching against Booleans should do. IIRC, there are two
positions, and a good argument for either side:
C<$foo ~~ True> means C<?$foo>; C<$foo ~~ False> means C<! ?$foo>
or
C<$foo ~~ True> means C<True>; C<$foo ~~ False> means C<False>
The first of these adds expressiveness to given/when, and behaves the
intuitive way when both the RHS of a match is a Boolean-valued variable
(I would intuitively expect C<$bool1 ~~ $bool2> to do Boolean equality).
The second means that the default case of a while can be syntactic sugar
for C<when (true)>, and I see that we went for the latter on those
grounds.
However, if we make the Whatever star on the RHS always match, we can
make C<default> equivalent to C<when (*)>, reminiscently of a shell
script, and we can also make C<$bool1 ~~ $bool2> do the obvious thing.
I don't immediately see any big wins for being able to say C<$foo ~~ *>,
nor any big loses for it no longer falling through to MMD.
Any thoughts?
--
"Twelve? Who needs twelve? Couldn't we make do with six?" -- Lew Grade,
<keyid 885b170d> trying to cut production costs on 'Jesus of Nazareth'
<http://surreal.istic.org/> "The illegal we do immediately,
the unconstitutional takes a little longer." Henry Kissinger, June 1972
Thread Next
-
~~ with *
by Daniel Hulme