Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm finding this hard to follow, but do you mean that:</p> <pre><code>x == a | b </code></pre> <p>will be syntax sugar equivalent to:</p> <pre><code>(x == a) || (x == b) </code></pre> <p>On the blog post you give this example:</p> <pre><code>1 + (2|3) </code></pre> <p>So the type of that expression is a pair of integers with the values 3 and 4, each representing one of the possible values. So we can also say:</p> <pre><code>4 == (1 + (2|3) 3 == (1 + (2|3) </code></pre> <p>and both of those would evaluate to true. So the operator <code>==</code> can compare a value with a kind of vector of values and will be <code>true</code> if any of the values in the vector are equal to the first value.</p> <p>This could be implemented using operator overloading in a few languages (although you'd have to explicitly "lift" simple values into a wrapper type before you could operate on them).</p> <p>Isn't it effectively the same as the union of two sets, and with == interpreted as "is a member of"? And operators like + being lifted so they apply to all the members of the set.</p> <p>And if you did (1|2) + (4|8) you'd get the equivalent of (5|9|6|10), because those are the four possible outcomes.</p> <p>Okay, from further examples you added, I see that <code>==</code> in fact requires the left and right sides to be the same set, rather than merely overlapping. But I still get the impression that your <code>|</code> is simply the union of two sets. What this entails (or means) will depend on what you do to all the other features of your language to deal with sets.</p> <p>Regarding your statement: </p> <blockquote> <p>The language is completely separated from the "time"-concept</p> </blockquote> <p>Have you looked much at pure functional languages like Haskell? Programs are a series of definitions with no known order of execution, you can only write pure functions with no side-effects, and hence the interpreter can order execution however it likes as long as values are available when really needed.</p> <p><strong>Update:</strong></p> <p>You added this to your question:</p> <pre><code>if(x == a | b) { // this } // can be written as if((x == a) | (x == b)) { // this } // which can be written as if(x == a) { // this } if(x == b) { // with this } </code></pre> <p>I wonder how you think that's going to be illuminating!</p> <p>The thing is, the first two versions have one block of code under the if. So if the third expanded version has two blocks, <em>they must be the same block</em>. In other words, this is just another way of writing:</p> <pre><code>if (x == a || x == b) { // this } </code></pre> <p>Where || is the traditional boolean OR. Which is exactly the question I first asked.</p> <p>Okay, one more time... You've now changed the syntax to indicate that you're doing unions and intersections. But then:</p> <pre><code>if(userkey I ("shift" U "a")) { // pressed both "shift" and the "a" key. </code></pre> <p>So <code>I</code> means take the intersection of the two sets... but <code>if</code> executes the code block under what circumstances? If the intersection is non-empty? Or is <code>I</code> in fact asking "are all the members of the set on the right members of the set on the left" And there are hints that <code>userkey</code> is replaced in the scope of the block by another value which actually just the set on the right.</p> <p>I'm going to bed.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload