Chris Oliver's Weblog
- All
- F3
- JavaFX
- Programming
Tuesday Jul 10, 2007
Bidirectional binding
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
Posted at 08:19AM Jul 10, 2007 by Christopher Oliver in JavaFX | Comments[10]

Posted by Kevin on July 10, 2007 at 02:16 PM PDT #
Posted by Tom on July 10, 2007 at 11:43 PM PDT #
Posted by Neal Gafter on July 11, 2007 at 09:14 AM PDT #
cheers,
Posted by Rémi Forax on July 11, 2007 at 01:58 PM PDT #
Posted by chris oliver on July 11, 2007 at 02:20 PM PDT #
I'm not sure your sarcasm is warranted. JavaFX isn't purporting to do anything that's mathematically impossible.
Bidirectional binding as far as supported is just an abstraction of the operational model you have anyway with property change listener patterns.
There are legitimate uses, e.g. with "bidirectional" widgets like text fields, check boxes, and radio buttons, where solvable equations provide a convenient mechanism for expressing such behavior.
Of course, you can also create cases that are unsolvable in which case you'll get a compile-time or runtime error.
At least, in such cases, JavaFX automatically detects the error, which is an improvement over the manual programmer managed property change listener approach, I think.
Posted by chris oliver on July 11, 2007 at 02:47 PM PDT #
Posted by MartinM on July 12, 2007 at 01:18 AM PDT #
Or put another way: working on language features is fun, and working tools is a lot of work and a bore. But it sure looks like tools are what's needed, not more language features.
Posted by Nick Parlante on July 12, 2007 at 02:50 PM PDT #
Posted by Spiff on July 12, 2007 at 06:06 PM PDT #
Posted by Erik on July 13, 2007 at 04:18 AM PDT #