On Tue, Aug 3, 2010 at 3:30 PM, David Green <david.gr...@telus.net> wrote:
> On 2010-08-02, at 2:35 pm, TSa (Thomas Sandlaß) wrote:
> > On Monday, 2. August 2010 20:02:40 Mark J. Reed wrote:
> >> [...] it's at least surprising. I'd expect (anything ~~ True) to be
> synonymous with ?(anything)
> > Note also that ($anything ~~ foo()) just throws away $anything.
> No; only if foo() returns a Bool.
How do you define that?
Any type which is compatible with Bool? What happens if, in a bold and
innovative stroke, some future revision of Perl 6 decides that Type is
compatible with Bool? Who wins in "$a ~~ Int"?
If my function returns "1 but False" will "1 ~~ func()" match?
I guess what I'm really asking, here, is do we use the first rule in the
smart-match table from S03 or is there some other priority system at work?
Do we consider only exact type matches and shunt everything else into Any or
do we call X.does(<type>)?
On a related note, I re-read S03 a bit and I've come to the conclusion that
the ~~ op (not the implicit smart match of given/when) should produce a
warning when its RHS is Bool (assuming we resolve what "is Bool" means,
above). There's just no good reason to confuse the issue that way, and the
Bool behavior of smart-matching is really just there to support given/when.
Beyond that, once we start getting into deeper warnings on semantic
mistakes, it's likely that it will make sense to warn at run-time if when is
asked to work on a boolean value which isn't the result of some form of
comparison. Again, it's just confusing for no benefit.
If we add the above warnings and the ones already listed in S03, then I
think I'll be fine with it. I understand why we want "when .foo == .bar" and
I can't think of a good way to replace it, so I'll buy that it's worth
making so many other obvious uses deprecated.
Email or GTalk: a...@ajs.com