Java FX Script bind

Just take a first look at the coding of Java FX Script. I'm quite curious on the keyword bind now.

First, I read this line:

image: Image { url: bind pix }

OK, this is good. So it means the image field has a url property that is bound to another variable pix. When pix changes, the url of the image changes also and it redraws. So, it's an automatic set/get/trigger/onChanged... two-way messaging mechanism. I like that.

However, looking back at what pix is, I see this line:

var pix = bind "http://somewhere/something.gif"

That's a little strange, pix is bound to a literal string? And then I see:

var x = bind 0

Totally ridiculous. This is like in C++, we should not write "int& x = 0" or "int\* x = &0". 

While x cannot be bound to a constant, something else can still be bound to x. I somehow understand that this bind keyword, when used after the assignment sign for a declared variable, seems to show that this variable itself is a "binding" (bind-able) variable, which means when it's assigned to something else, it's more sort of a symlink/alias than an assignment. If this is right, I'd rather like the grammar to be changed a little to use bind as a modifier:

bind x = 0 

Back to the first line, what does "url: bind pix" mean? This "bind" is not a modifier on pix, it's already declared as bind somewhere else. Is it on url? Not likely, because url is defined as a property of the Image class, being "binding" or not should have already been decided at the definition of Image. So this bind keyword here, is used to declare a binding relation between 2 declared variables. This looks like in C++, we change a normal variable into a reference.

int x = 0;    // x is a normal variable
int y = 1; // y is another
&x = y; // x is redeclared to be a reference of y

Note: I admit I'm not familiar with data binding, or RAD tools, or any event driven programming. I even don't know if this "bind" is the root form of that "bound".

Comments:

java xfに関する説明の資料(参考:英語のweb上)

Posted by ju young su on July 02, 2007 at 07:41 AM CST #

I just don't understand why the grammar for "bind" is defined this way. It seems "= bind" and ": bind" are too different.

Posted by Weijun on July 02, 2007 at 07:44 AM CST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

This blog has a comments managing system that requires me to approve each comment manually. Please do not re-post and I will reply it (if I have an answer) when I get pinged.

Search

Top Tags
Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today