Does this language feature already exists?

Posted by Pindatjuh on Stack Overflow See other posts from Stack Overflow or by Pindatjuh
Published on 2010-03-24T23:10:25Z Indexed on 2010/03/24 23:13 UTC
Read the original article Hit count: 303

I'm currently developing a new language for programming in a continuous environment (compare it to electrical engineering), and I've got some ideas on a certain language construction.

Let me explain the feature by explanation and then by definition;

x = a | b;

Where x is a variable and a and b are other variables (or static values).

if(x == a) {
    // all references to "x" are essentially references to "a".
}
if(x == b) {
    // same but with "b"
}
if(x != a) {
    // ...
}
if(x == a | b) {
    // guaranteed that "x" is '"a" | "b"'; interacting with "x"
    // will interact with both "a" and "b".
}
// etc.

In the above, all code-blocks are executed, but the "scope" changes in each block how x is interpreted. In the first block, x is guaranteed to be a: thus interacting with x inside that block will interact on a. The second and the third code-block are only equal in this situation (because not b only remains a). The last block guarantees that x is at least a or b.

Further more; | is not the "bitwise or operator", but I've called it the "and/or"-operator. It's definition is:

"|" = "and" | "or"

(On my blog, http://cplang.wordpress.com/2009/12/19/binop-and-or/, is more (mathematical) background information on this operator. It's loosely based on sets.)

I do not know if this construction already exists, so that's my question: does this language feature already exists?

© Stack Overflow or respective owner

Related posts about language-features

Related posts about exists