On Tue, Jan 05, 2010 at 11:52:42AM -0500, Solomon Foster wrote:
: On Tue, Jan 5, 2010 at 11:36 AM, Ovid
: <publiustemp-perl6langua...@yahoo.com> wrote:
: > --- On Tue, 5/1/10, Solomon Foster <colo...@gmail.com> wrote:
: >
: >> From: Solomon Foster <colo...@gmail.com>
: >
: >> > Is this a bug or just documented behavior that I don't
: >> know about?
: >>
: >> fail just returns an uncalled exception.  What does
: >> that do in a where block?
: >
: > I knew it returned an uncalled exception, but I'm still not expecting the 
sub call to be skipped silently due to a constraint failure.  Silent failures 
are bad :)
: Good point.  :)

I think it's fine to return a failure, but we'll need to distinguish two
different kinds of constraint checks, mandatory vs discretionary.  In

    my Constraint $x = 42;

the Constraint is mandatory, and should die if the constraint check
returns a failure.  In the typical multi-dispatch, however, you
just want a failure to mean "look elsewhere".  (You can still
force a die there if you really want it.)

To the first approximation, a mandatory check requires a defined
"where" return value, while a discretionary check only requires a
true value.

(Note that a constraint on the parameter of an "only" sub is already
mandatory, not discretionary, at least in the sense that the call
will fail if the binding is unsuccessful.  So that probably falls
out naturally, though perhaps loses track of the failure message


Reply via email to