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

Is there a way to use only one-way or one-time binding?

Posted by Kevin on July 10, 2007 at 07:16 AM PDT #

One time binding... Isn't that an assign? Like: var a = true; var b = not a; B was binded to a once.

Posted by Tom on July 10, 2007 at 04:43 PM PDT #

In 1970, it was proven that Hilbert's tenth problem is unsolvable. It seems that the power of JavaFX transcends mathematics!

Posted by Neal Gafter on July 11, 2007 at 02:14 AM PDT #

what is the value of x and y ?
var x = 10;
var z = 10;
var y = bind x+z;

y = 5;



Posted by Rémi Forax on July 11, 2007 at 06:58 AM PDT #

@remi If you tried it, you'd see the assignment to y is rejected in this case, since y = x + z doesn't have a 1-place inverse function.

Posted by chris oliver on July 11, 2007 at 07:20 AM 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 07:47 AM PDT #

As I recall, Hilbert's tenth problem is defined over the set of all integers, or equivalently over the set of all naturals. Over any finite subset it would seem obvious that the solvability of any Diophantine equation could be determined in a finite number of steps simply by trying every possible solution. Since computers have annoyingly finite memory, I don't really see the problem. </maths pedant>

Posted by MartinM on July 11, 2007 at 06:18 PM PDT #

I love the idea of an open/open-source technology in this niche, such as JavaFX. That said I think working on JavaFX Script features, such as this one, is huge mistake. Fancy features are not needed there. If JavaFX gets any traction, it will be via code emtited by some tool anyway. That, and nobody wants to learn yet another language for these things, so just build out something super minimal; just enough to support what the tool needs. Put energy into (a) fast Java startup time (ok, that's be worked on), and (b) building out the tools that emit this stuff. I really want something open in the JavaFX niche to succeed, but I have a very bad feeling about these language features. It looks exactly like a grad student dorking around with some one-off language for fun, but without really weighing if there's an audience.

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 07:50 AM PDT #

I think this looks pretty cool. I've always found the PropertyChangeListener a bit cumbersome so I hope this will work better. Off-topic question; Is there a grammar file for Java FX Script available somewhere? I was thinking about creating a Java FX plugin for IntelliJ.

Posted by Erik on July 12, 2007 at 09:18 PM PDT #

thank you

Posted by travesti on September 13, 2008 at 09:31 AM PDT #

Posted by matbaa on June 22, 2009 at 03:06 AM PDT #

thanks for good work.

Posted by Egitim on December 11, 2010 at 05:24 AM PST #

Simple and Nice example !

Posted by شات on December 15, 2010 at 03:38 AM PST #

it's very good, thank you very much, wish you merry xmas to you and your family.

Posted by batterie on December 23, 2010 at 03:49 PM PST #

it's very good, thank you very much, wish you merry xmas to you and your family.

Posted by sohu on March 20, 2011 at 11:34 AM PDT #

it's very good, thank you very much, wish you merry xmas to you and your family.

Posted by sohu on March 20, 2011 at 11:35 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed



« August 2016