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)); };
Predicates in .NET/C# 2.0 are delegates, not a class like my implementation
so it's not possible (using C#) to add overloaded operators to the Predicate
delegate. There is no such limitation in the runtime or IL.
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....
^Tum 2 1720
"Thong Nguyen" <tu*@veridicus. spamless.com> wrote in message
news:O2******** ******@TK2MSFTN GP15.phx.gbl... 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.
"Thong Nguyen" <tu*@veridicus. spamless.com> wrote in message
news:O2******** ******@TK2MSFTN GP15.phx.gbl... 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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: dayzman |
last post by:
Hi,
M'm writing a program to output the results of transforming logical
predicates using deMorgan's. Does anyone know of a library that handles
logical predicates?
Cheers,
Michael
|
by: Michael Andersson |
last post by:
Given a set of classes
class A { enum [ ID = 0x0001} };
class B { enum [ ID = 0x0002} };
class B { enum [ ID = 0x0004} };
I wish to generate a composite class, perhaps using something like
Alexandrescu's typelists
(pseudo-code:)
|
by: AshifToday |
last post by:
this was my and my frineds little project in earlier classes,
the program seperates the composite and prime numbers in two sections
of the screen
=====================
/*
This program has been made by A & A Group.
Muhammad Ali: Roll # 1462 Class A-2 , B.Sc.(Hons.) in C.S.
|
by: Thomas A. Anderson |
last post by:
I am a bit confused in creating a composite primary key. I have three table
with two of the tables containing primary keys. I have two of the tables
(each with a primary key) having one to many relations with the table
containing no primary key. Do I just create two primary keys on the table
that does not contain any primary key for this to become a composite primary
key?
Thank you in advance!
Still a newbie,
|
by: Thong Nguyen |
last post by:
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
| |
by: Ismail Rajput |
last post by:
Is there any option we can use Composite DataKeyField in the DataList and
DataGrid?
|
by: dave.dolan |
last post by:
Basically I'd like to implement the composite design pattern with leaves that
are either of reference or value types, but even using generics I can't seem
to avoid boxing (using ArrayList or Object)
Is this even possible, or is the composite pattern doomed to use the
System.Object type forever?
I have tried using interfaces with generics, but I always stumble on the
Value property (when trying to return the value of a particular node)
|
by: raylopez99 |
last post by:
Inspired by Jon, I did a demo prorgram showing three ways to declare
predicates, in for example the "FindIndex" and "FindLastIndex" methods
of Lists, but in general you can do this for any predicate.
Note the most compact way is to use Lambda notation and anonymous
functions, the first way shown below. The most 'intuitive' way is to
'hard code' the predicate using a predicate method, the second way
shown below, but the best way (for me)...
|
by: Arun Srinivasan |
last post by:
Hi
I was using a query previously, that was efficient
select * from table where pred1 and pred2 and pred3;
Later I was asked to introduce new ones, but they were not based on
table columns but variables declared in SP.
select * from table where pred1 and pred2 and pred3 and variable1
='number1 and variable2 =number2;
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |