[Date Index] [Thread Index] [Author Index]
Re: Named patterns forbidden in Except?
On 20/06/10 08:46, Carlos C=E9sar de Ara=FAjo wrote: > David Bailey wrote: > >>> I guess the point is that you could never use the name - because in your > >>> example, if x took a value, Except would fail to match by definition! > > Well, this is not a valid argument: I'm not using an isolated Except in a > transformation rule. According to the documentation, "Except[c] is a > pattern object which represents any expression except one that matches c." > In particular, given a pattern patt, we should have, for all expressions > expr, > > MatchQ[expr, Except[patt]] iff !MatchQ[expr,patt] > > But there are (many!) situations where a named patt is useful in > !MatchQ[expr,patt]. Example: my definition of FunctionQ. That definition > works with a named patt in MatchQ, so it should work with Except instead. > The name belongs to the scope of the rule, so for example: In:= MatchQ[7, x_Integer]; x Out= x I do admit, the rule is a bit strange because it forbids constructions like: Except[x_Integer /; testQ[x]] Anyway, the restriction was obviously put in deliberately, so it is unlikely to become classed as a bug. David Bailey http://www.dbaileyconsultancy.co.uk