I had a shower-thought. Tell me how stupid it is.
In programming, I get tired of typing out
and
I want to abbreviate this.
Proposed syntax:
checks if var is between a and b
checks if var is outside of the range a to b
further fun:
and
could be the same as the above checks but inclusive of a and b
If only one end of the range is to be inclusive, then you do it the old way without these new comparison operators.
Is this somehow stupid? Is it already a thing in some language? Is it possible to implement in popular languages? I know that C++ allows operator overloading, but I don't know if that includes making up new comparison operators. I suppose it would be best done in some preprocessor/macro way.
In programming, I get tired of typing out
Code:
var > a && var < b
Code:
var < a || var > b
I want to abbreviate this.
Proposed syntax:
Code:
var >< a:b
Code:
var <> a:b
further fun:
Code:
var >=< a:b
Code:
var <=> a:b
If only one end of the range is to be inclusive, then you do it the old way without these new comparison operators.
Is this somehow stupid? Is it already a thing in some language? Is it possible to implement in popular languages? I know that C++ allows operator overloading, but I don't know if that includes making up new comparison operators. I suppose it would be best done in some preprocessor/macro way.
, please tell me that this is being discovered in the construction phase of your latest mad science project, and not while it's in use. :uhh: