<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-5210758134406178854.post1281779383681970658..comments</id><updated>2010-02-22T08:23:47.399-05:00</updated><category term='javafx'/><category term='xml'/><category term='tools'/><category term='javascript'/><category term='java'/><category term='scalability'/><category term='debugging'/><category term='refactoring'/><category term='process'/><category term='patterns'/><category term='security'/><category term='dogma'/><category term='jsp'/><category term='maven'/><category term='implementation'/><category term='philosophy'/><category term='open source'/><category term='algorithms'/><category term='bash'/><category term='job-search'/><category term='website management'/><category term='test-driven-development'/><category term='data structures'/><category term='git'/><category term='persistence'/><category term='html'/><category term='user interface'/><category term='book review'/><category term='optimization'/><category term='templating'/><category term='design'/><category term='performance'/><category term='taglib'/><title type='text'>Comments on blog.kdgregory.com: JavaFx: Interesting Language Features</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.kdgregory.com/feeds/1281779383681970658/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5210758134406178854/1281779383681970658/comments/default'/><link rel='alternate' type='text/html' href='http://blog.kdgregory.com/2010/02/javafx-interesting-language-features.html'/><author><name>kdgregory</name><uri>http://www.blogger.com/profile/03491264911815834181</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5210758134406178854.post-3814104002970642789</id><published>2010-02-22T08:23:47.399-05:00</published><updated>2010-02-22T08:23:47.399-05:00</updated><title type='text'>Thanks for the comment. I saw that Sun forum threa...</title><content type='html'>Thanks for the comment. I saw that Sun forum thread that you mentioned, but one part of smarks&amp;#39; reply stood out:&lt;br /&gt;&lt;br /&gt;&amp;quot;HOWEVER I recommend that you DO NOT USE the &amp;quot;bind lazy&amp;quot; construct. Its semantics are ill-defined, especially in the presence of triggers, and there are bugs in it. If you rely on it you will probably get yourself into trouble. We certainly have. It&amp;#39;s undocumented for a reason.&amp;quot;&lt;br /&gt;&lt;br /&gt;I&amp;#39;m not convinced that lazy evaluation of bound expressions would improve performance in practice: if you&amp;#39;re binding an expression, particularly in a UI, you&amp;#39;ll be evaluating that expression on a regular basis (eg, whenever the GUI is repainted). In such cases, you don&amp;#39;t want to check that expression to see what has changed, or worse, re-evaluating the entire expression.&lt;br /&gt;&lt;br /&gt;I think the JavaFx team would be better served by making &amp;quot;lazy&amp;quot; a separate keyword, with different semantics: &amp;quot;bind&amp;quot; would imply propagation, &amp;quot;lazy&amp;quot; would imply evaluation. For example, you could specify a function parameter as &amp;quot;lazy,&amp;quot; and the argument would not be evaluated unless it&amp;#39;s referenced -- perhaps never, if it&amp;#39;s in the &amp;quot;wrong&amp;quot; place in an &amp;quot;if&amp;quot; or conditional expression.&lt;br /&gt;&lt;br /&gt;---&lt;br /&gt;&lt;br /&gt;And a comment for people reading these comments and wondering what they mean: they belong on the next posting.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5210758134406178854/1281779383681970658/comments/default/3814104002970642789'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5210758134406178854/1281779383681970658/comments/default/3814104002970642789'/><link rel='alternate' type='text/html' href='http://blog.kdgregory.com/2010/02/javafx-interesting-language-features.html?showComment=1266845027399#c3814104002970642789' title=''/><author><name>kdgregory</name><uri>http://www.blogger.com/profile/03491264911815834181</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.kdgregory.com/2010/02/javafx-interesting-language-features.html' ref='tag:blogger.com,1999:blog-5210758134406178854.post-1281779383681970658' source='http://www.blogger.com/feeds/5210758134406178854/posts/default/1281779383681970658' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-2106282590'/></entry><entry><id>tag:blogger.com,1999:blog-5210758134406178854.post-2027010797948437255</id><published>2010-02-20T09:33:42.951-05:00</published><updated>2010-02-20T09:33:42.951-05:00</updated><title type='text'>Hi Keith,

About lazy evaluation... I&amp;#39;ve been ...</title><content type='html'>Hi Keith,&lt;br /&gt;&lt;br /&gt;About lazy evaluation... I&amp;#39;ve been puzzled on this topic for a while too.  Although it&amp;#39;s not documented (well? / at all?), JavaFX 1.2 does appear to have some support for lazy evaluation.&lt;br /&gt;&lt;br /&gt;Here is an example of a lazy vs non-lazy bind:&lt;br /&gt;&lt;br /&gt;=== CODE ===&lt;br /&gt;&lt;br /&gt;class NonLazy {&lt;br /&gt;  public var x: Number = 0;&lt;br /&gt;  public def y: Number = bind x on replace {&lt;br /&gt;    println(&amp;quot;NonLazy y has been replaced!&amp;quot;);&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class Lazy {&lt;br /&gt;  public var x: Number = 0;&lt;br /&gt;  public def y: Number = bind lazy x on replace {&lt;br /&gt;    println(&amp;quot;Lazy y has been replaced!&amp;quot;);&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;println(&amp;quot;-- Creating nonLazy --&amp;quot;);&lt;br /&gt;def nonLazy = NonLazy { }&lt;br /&gt;println(&amp;quot;About to set nonLazy.x&amp;quot;);&lt;br /&gt;nonLazy.x = 42;&lt;br /&gt;println(&amp;quot;About to query nonLazy.y&amp;quot;);&lt;br /&gt;def nonLazyY = nonLazy.y;&lt;br /&gt;println(&amp;quot;nonLazy.y = {nonLazyY}&amp;quot;);&lt;br /&gt;&lt;br /&gt;println(&amp;quot;-- Creating lazy (laze) --&amp;quot;);&lt;br /&gt;def laze = Lazy { }&lt;br /&gt;println(&amp;quot;About to set laze.x&amp;quot;);&lt;br /&gt;laze.x = 42;&lt;br /&gt;println(&amp;quot;About to query lazy.y&amp;quot;);&lt;br /&gt;def lazyY = laze.y;&lt;br /&gt;println(&amp;quot;laze.y = {lazyY}&amp;quot;);&lt;br /&gt;&lt;br /&gt;=== CODE ===&lt;br /&gt;&lt;br /&gt;If you execute it, you should get the following output:&lt;br /&gt;&lt;br /&gt;-- Creating nonLazy --&lt;br /&gt;NonLazy y has been replaced!&lt;br /&gt;About to set nonLazy.x&lt;br /&gt;NonLazy y has been replaced!&lt;br /&gt;About to query nonLazy.y&lt;br /&gt;nonLazy.y = 42.0&lt;br /&gt;-- Creating lazy (laze) --&lt;br /&gt;About to set laze.x&lt;br /&gt;About to query lazy.y&lt;br /&gt;Lazy y has been replaced!&lt;br /&gt;laze.y = 42.0&lt;br /&gt;&lt;br /&gt;As you can see, the lazy y value is not replaced until it is queried.&lt;br /&gt;&lt;br /&gt;It&amp;#39;s also possible to use the lazy keyword with a bound function (again just after the bind keyword), with similar results.  Remember to declare the function itself as bound, as described here by Jonathan Giles:&lt;br /&gt;    http://jonathangiles.net/blog/?p=460&lt;br /&gt;&lt;br /&gt;There is a little discussion of lazy binding on this Sun forum topic:&lt;br /&gt;  http://forums.sun.com/thread.jspa?threadID=5427223&lt;br /&gt;In particular, Amy Fowler and Chris Oliver both have public examples that use the lazy keyword (linked from the first post).&lt;br /&gt;&lt;br /&gt;I hope the above helps.  Let&amp;#39;s hope that the JavaFX team are listening and improve their documentation! :-)&lt;br /&gt;&lt;br /&gt;Jonathan Merritt.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5210758134406178854/1281779383681970658/comments/default/2027010797948437255'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5210758134406178854/1281779383681970658/comments/default/2027010797948437255'/><link rel='alternate' type='text/html' href='http://blog.kdgregory.com/2010/02/javafx-interesting-language-features.html?showComment=1266676422951#c2027010797948437255' title=''/><author><name>Jonathan Merritt</name><uri>http://www.blogger.com/profile/08148499902760061921</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_S4SxpnrU6X8/SFsz89s66BI/AAAAAAAAAAM/QzQ1ZosCl4U/S220/n218101316_2077.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.kdgregory.com/2010/02/javafx-interesting-language-features.html' ref='tag:blogger.com,1999:blog-5210758134406178854.post-1281779383681970658' source='http://www.blogger.com/feeds/5210758134406178854/posts/default/1281779383681970658' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1105120986'/></entry></feed>
