C++ feature request - the !? operator

Posted on:October 05 2005

There are so many operators in C++, for example '!=', '*', '/=' and whatever. I'd like a new one: The '!?' operator. And I'd like to have the possibility to write it everywhere. Really, everywhere. Its default functionality should be that it does nothing at all. With this, it would be possible to enrich your code easily. Example: You have to work with code which looks like this:
[++*foobar]-=(baz*)--bar + x ? 0xff:0x1<< 1; 
Not easy to read, eh? But with the !? operator, this will change dramatically:
!? [++*foobar !?!?]-=(baz*)--bar !?!? + x ? 0xff:0x1<< 1; !?!?!?!?!?!?
Within just a fraction of a second, you'll now immediately see that you won't have to spend time to try to understand that code. Thanks, !? operator.





Comments:


Sure, it's easy to write crappy code by adding lots of operators. It's also easy to write crappy code without them, as the first example well demonstrates :) But rather than "Vector::dot(v1, v2)", I _would_ like to write "v1 · v2". It's clear, concise, and has a firm grounding outside of my personal project using it.

For another example of a place where more operators would be good ("::=", " ", postfix ops), see the Spirit parsing library (http://www.boost.org/libs/spirit/).
Sfiera
Quote
2005-10-05 22:16:00


#define !?
avi
Quote
2005-10-05 22:26:00


*rofl*
Maverick
Quote
2005-10-06 09:19:00


with
#define oag(x)
#define what(x)
you could make it
what(?) [++*foobar oag(!)] -= (baz*) oag(!) --bar + x ? 0xff : 0x1<<1; oag(!!)
bertl
Quote
2005-10-06 10:48:00


by the way: what do you subscript? (or is it basically to have the compiler do the !? stuff itself in the output?)
bertl
Quote
2005-10-06 10:52:00


wait... what!?
Midnight
Quote
2005-10-13 08:47:00


Add comment:


Posted by:


Enter the missing letter in: "Internat?onal"


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons