]> ocean-lang.org Git - ocean-D/blobdiff - Ocean-operators
updates
[ocean-D] / Ocean-operators
index 7c75e6117739472ecb36ad6ff0e0a7e0f184e521..d70058b19df36c9832cc463ab6f9b2cd4bf8aeeb 100644 (file)
@@ -91,3 +91,35 @@ Hmm..  not what I imagined.  But what I imaging suggested that left-association
  a op b op c -> (a op b) op c
 requires that we reduce even when we could shift, ... maybe .... I should leave this
 until I do precedence.
+
+--------------------------
+
+Thinking about bit operators.
+
+#foo  is 2^foo
+So #12-#4 is
+    1000000000000 -
+            10000
+=    111111110000
+which is bits 4 thru 11
+
+I'm wondering if it is useful to have a field-select operator,
+which could be '#' as infix (rather than prefix) so
+
+  var # field
+
+would be an lval which can only modify the selected bits
+
+  var # #12-#4 = #6-#4
+would clear bits 6-11.  Doesn't actually read very well, does it?
+Probably better to use field syntax, with a way to declare fields for an int.
+This would be a record.
+
+Still.
+   var &~= #4
+   var |= #4
+to clear and set bits looks OK.
+But ... what syntax do I want for test-and-set?  More genericly cmpxchg.
+An operator that modifies a variable is something I wanted to avoid.
+  var ? oldval = newval
+could 'use false' if it fails.