[PEAK] Rules clarification
Phillip J. Eby
pje at telecommunity.com
Wed Feb 27 23:56:44 EST 2008
Sorry I didn't reply to this sooner; I meant to think about it before
replying and then it scrolled out of my immediate view and I forgot about it.
At 06:47 PM 2/15/2008 +0200, Sergey Schetinin wrote:
>I've noticed that "when" function accepts anything as it's second
>parameter (not just tuples),
Yes; all that is required is that it be something which can "imply" a
type tuple (i.e. using the peak.rules.implies() function).
> what does this declaration would mean
>then (maybe nothing and it should throw an exception?)
>
> >>> from peak.rules import *
> >>> @abstract
>... def test(foo):
>... pass
>...
> >>> @when(test, int) # <--------- this is what I'm talking about
>... def test_int(foo):
>... print foo
>...
It indeed means nothing. Whether it should throw an exception is a
more complex problem. Right now, the default for testing implication
between two different types is to say that neither implies the
other. This is a sensible default, except for where it's misleading
in this case. So I could add a specific rule to catch it and throw
an exception, but I'm wondering how many such special cases would need adding.
More information about the PEAK
mailing list