Re: Adding early ambiguity warnings to PEAK-Rules?

Николай <[email protected]> Thu, 19 Aug 2010 15:17:38 +0300
Newsgroups gmane.comp.python.peak
Message-ID <[email protected]>
> There is one other downside to immediate ambiguity checks, though, and
> that's rule ordering.  If our main example is checked immediately, then you
> can't write your rules like this:
>
>  when(f, (A, B))(...)
>  when(f, (B, A))(...)
>  when(f, (B, B))(...)
>
> Because you'll get a warning on the second rule.  Instead, you'll have to do
> this:
>
>  when(f, (B, B))(...)
>  when(f, (A, B))(...)
>  when(f, (B, A))(...)
>
> Which seems a bit unfortunate, as it's basically forcing you to put the
> special case before the general cases!  (Which is bad for both the reader
> and writer of the code.)

Wild idea: use something like

when(f, (A,B), delaycheck)(...)
when(f, (B,A), delaycheck)(...)

del delaycheck

and trigger check when delaycheck is collected or at first call f() to
warn about missing 'del delaycheck'. If no delaycheck is provided do
checks normal way

Niki

-- 
|  (\_/)  This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination