Bidirectional binding

how-to
Jul 10, 20071 min

In addition to corrections to local variable binding the next update of the JavaFX interpreter will include extended bidirectional binding, including of logical negation, unary minus, arithmetic, and sequence indexing. Here’s a JavaFXPad example you can try out:


// logical negation
var a = true;
var b = bind not a;
assert b == false;
b = true;
assert a == false; // passes

// arithmetic
var x = 10;
var y = bind -x + 100;
assert y == 90;
y = 40;
assert x == 60; // passes

// sequence elements
var seq = [1, 2, 3];
var elem1 = bind seq[1];
elem1 = 500;
assert seq == [1, 500, 3]; // passes
delete seq[1];
assert elem1 == 3; // passes
insert 0 as first into seq;
assert elem1 == 1; // passes
var value = bind elem1;
value = 999;
assert seq == [0, 999, 3]; // passes