"Thong Nguyen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I wrote my own Predicate class for .NET 1.1 which allowed composite
>predicates using operator overloading...
>
> for example:
>
> Predicate p1 = {...};
> Predicate p2 = {...};
>
> Predicate p1andp2 = ~(p1 ^ p2); // ^ is the AND operator in logic notation
>
> which is requivalent to:
>
> Predicate p1andp2 = delegate(object o) { return !(p1(o) && p2(o)); };
<snip>
> What I would like to see is Microsoft add logical compositing operators
> for the Predicate delegate in Whidbey. Predicates have a potential to be
> used pretty much everywhere where a boolean decision needs to be made (for
> flexibility reasons, it can/should replace bool in many areas of the BCL)
> and being able to combine many distinct predicates into a single predicate
> with an easy to use syntax would be nice....
I think you could easily just provide a method to achieve this(using dynamic
methods). While compositing has some interesting concepts, I'm not sure its
really worth *THAT* much as to change the language for one specific case.
Also, even though ^ may be and in logic notation, using it in C# is a
mistake, IMHO. You'll confuse far more people by using an operator the
language already has noted as xor than you will by using one the logic does
not use.
It is an interesting concept, however.
|