<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Pointer Syntax for Java Closures</title>
	<atom:link href="http://warpedjavaguy.wordpress.com/2008/02/21/pointer-syntax-for-java-closures/feed/" rel="self" type="application/rss+xml" />
	<link>http://warpedjavaguy.wordpress.com/2008/02/21/pointer-syntax-for-java-closures/</link>
	<description>Observations of everyday Java phenomena</description>
	<lastBuildDate>Fri, 18 Dec 2009 05:32:07 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: ankara  nakliyat</title>
		<link>http://warpedjavaguy.wordpress.com/2008/02/21/pointer-syntax-for-java-closures/#comment-313</link>
		<dc:creator>ankara  nakliyat</dc:creator>
		<pubDate>Sun, 08 Jun 2008 17:31:16 +0000</pubDate>
		<guid isPermaLink="false">http://warpedjavaguy.wordpress.com/?p=30#comment-313</guid>
		<description>very nice article.</description>
		<content:encoded><![CDATA[<p>very nice article.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: WarpedJavaGuy</title>
		<link>http://warpedjavaguy.wordpress.com/2008/02/21/pointer-syntax-for-java-closures/#comment-284</link>
		<dc:creator>WarpedJavaGuy</dc:creator>
		<pubDate>Mon, 10 Mar 2008 23:49:07 +0000</pubDate>
		<guid isPermaLink="false">http://warpedjavaguy.wordpress.com/?p=30#comment-284</guid>
		<description>The star would be used to denote closures in Java and not pointers &lt;i&gt;per se&lt;/i&gt;.  Closures are like methods in that they can accept input values and return an output value.  Take the signature of a method and add a star after the return type.  The result is no more uglier than the method signature itself.

Closures are pointers to methods or blocks of code that capture the environment in which they are defined.  They are most likely coming to Java soon.  Now which nemesis would you prefer?  

Java* or {=&gt;Java}</description>
		<content:encoded><![CDATA[<p>The star would be used to denote closures in Java and not pointers <i>per se</i>.  Closures are like methods in that they can accept input values and return an output value.  Take the signature of a method and add a star after the return type.  The result is no more uglier than the method signature itself.</p>
<p>Closures are pointers to methods or blocks of code that capture the environment in which they are defined.  They are most likely coming to Java soon.  Now which nemesis would you prefer?  </p>
<p>Java* or {=&gt;Java}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rocko</title>
		<link>http://warpedjavaguy.wordpress.com/2008/02/21/pointer-syntax-for-java-closures/#comment-283</link>
		<dc:creator>Rocko</dc:creator>
		<pubDate>Mon, 10 Mar 2008 16:04:01 +0000</pubDate>
		<guid isPermaLink="false">http://warpedjavaguy.wordpress.com/?p=30#comment-283</guid>
		<description>Naaahhhh, please. Don&#039;t use the star.
It is so plain ugly. More important: What people love about Java and hate about C are pointers. Remember your first C lessons?

Psychologically it&#039;d be a desaster to introduce the *pointer-style to java because everyone will think that their nemesis has finally arrived in java to make them roast on a hellish fire. Painful.</description>
		<content:encoded><![CDATA[<p>Naaahhhh, please. Don&#8217;t use the star.<br />
It is so plain ugly. More important: What people love about Java and hate about C are pointers. Remember your first C lessons?</p>
<p>Psychologically it&#8217;d be a desaster to introduce the *pointer-style to java because everyone will think that their nemesis has finally arrived in java to make them roast on a hellish fire. Painful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: WarpedJavaGuy</title>
		<link>http://warpedjavaguy.wordpress.com/2008/02/21/pointer-syntax-for-java-closures/#comment-279</link>
		<dc:creator>WarpedJavaGuy</dc:creator>
		<pubDate>Wed, 05 Mar 2008 00:18:03 +0000</pubDate>
		<guid isPermaLink="false">http://warpedjavaguy.wordpress.com/?p=30#comment-279</guid>
		<description>I should stress that closures really are more than just mere method pointers.  They also capture all the bindings in the environment in which they are defined and therefore have access to the variables defined in the enclosing scope.  This is true regardless of the syntax.</description>
		<content:encoded><![CDATA[<p>I should stress that closures really are more than just mere method pointers.  They also capture all the bindings in the environment in which they are defined and therefore have access to the variables defined in the enclosing scope.  This is true regardless of the syntax.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: WarpedJavaGuy</title>
		<link>http://warpedjavaguy.wordpress.com/2008/02/21/pointer-syntax-for-java-closures/#comment-277</link>
		<dc:creator>WarpedJavaGuy</dc:creator>
		<pubDate>Tue, 04 Mar 2008 11:29:12 +0000</pubDate>
		<guid isPermaLink="false">http://warpedjavaguy.wordpress.com/?p=30#comment-277</guid>
		<description>I am just questioning why we should not consider a pointer syntax that is more in line with Java method signatures.  If the general consensus is that this pointer syntax is too cryptic and does not belong in Java then so be it.  It is interesting though that it does yield a less verbose syntax.  That does not automatically mean that it is better though.  A better syntax is one that is easier to read and easier to use.  I personally find the BGGA syntax very easy to read and quite like it.  But I am here wanting to explore whether or not a more familiar and less verbose variant form of the C/C++ style pointer syntax has any appeal. 

@Talden,

The TYPE part of the variable declaration using this pointer syntax can be defined as follows:

ReturnType* ((p1, p2, ...pN) throws e1, e2, ...eN)

Consider the following Java method signature that accepts two parameters of type File and int, returns a String, and throws an IOException

&lt;code&gt;String (File, int) throws IOException&lt;/code&gt;

Closures for this method would be declared as follows:

BGGA syntax:
&lt;code&gt;{File, int =&gt; String throws IOException}&lt;/code&gt;

Pointer syntax:
&lt;code&gt;String* ((File, int) throws IOException)&lt;/code&gt;

Stephen Colebourne&#039;s generic BGGA converter example (used in this post) both accepts and returns closures.  Lets add exceptions to that and compare:

BGGA syntax:

public {T =&gt; U throws E} converter({=&gt; T} a, {=&gt; U} b, {T =&gt; U throws E} c) {
&#160; return {T t =&gt; a.invoke().equals(t) ? b.invoke() : c.invoke(t)};
}

Pointer syntax:

public U* ((T) throws E) converter(T* a, U* b, U* ((T) throws E) c) {
&#160; return (T t) {a.invoke().equals(t) ? b.invoke() : c.invoke(t)};
}

@Xavi,

Thanks for your explanation.  The BGGA syntax certainly does have a certain clarity about it.  I think a lot of people would agree that as far as initial impressions go, both look rather cryptic.

@Alain,

You are scaring me when you use names like funcPtr ;)
I do agree with your summary in that the syntax should look very Java method like and should (unlike C/C++) enforce the principle that the variable name should be the last token.</description>
		<content:encoded><![CDATA[<p>I am just questioning why we should not consider a pointer syntax that is more in line with Java method signatures.  If the general consensus is that this pointer syntax is too cryptic and does not belong in Java then so be it.  It is interesting though that it does yield a less verbose syntax.  That does not automatically mean that it is better though.  A better syntax is one that is easier to read and easier to use.  I personally find the BGGA syntax very easy to read and quite like it.  But I am here wanting to explore whether or not a more familiar and less verbose variant form of the C/C++ style pointer syntax has any appeal. </p>
<p>@Talden,</p>
<p>The TYPE part of the variable declaration using this pointer syntax can be defined as follows:</p>
<p>ReturnType* ((p1, p2, &#8230;pN) throws e1, e2, &#8230;eN)</p>
<p>Consider the following Java method signature that accepts two parameters of type File and int, returns a String, and throws an IOException</p>
<p><code>String (File, int) throws IOException</code></p>
<p>Closures for this method would be declared as follows:</p>
<p>BGGA syntax:<br />
<code>{File, int =&gt; String throws IOException}</code></p>
<p>Pointer syntax:<br />
<code>String* ((File, int) throws IOException)</code></p>
<p>Stephen Colebourne&#8217;s generic BGGA converter example (used in this post) both accepts and returns closures.  Lets add exceptions to that and compare:</p>
<p>BGGA syntax:</p>
<p>public {T =&gt; U throws E} converter({=&gt; T} a, {=&gt; U} b, {T =&gt; U throws E} c) {<br />
&nbsp; return {T t =&gt; a.invoke().equals(t) ? b.invoke() : c.invoke(t)};<br />
}</p>
<p>Pointer syntax:</p>
<p>public U* ((T) throws E) converter(T* a, U* b, U* ((T) throws E) c) {<br />
&nbsp; return (T t) {a.invoke().equals(t) ? b.invoke() : c.invoke(t)};<br />
}</p>
<p>@Xavi,</p>
<p>Thanks for your explanation.  The BGGA syntax certainly does have a certain clarity about it.  I think a lot of people would agree that as far as initial impressions go, both look rather cryptic.</p>
<p>@Alain,</p>
<p>You are scaring me when you use names like funcPtr <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
I do agree with your summary in that the syntax should look very Java method like and should (unlike C/C++) enforce the principle that the variable name should be the last token.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alain Coetmeur</title>
		<link>http://warpedjavaguy.wordpress.com/2008/02/21/pointer-syntax-for-java-closures/#comment-276</link>
		<dc:creator>Alain Coetmeur</dc:creator>
		<pubDate>Tue, 04 Mar 2008 09:49:21 +0000</pubDate>
		<guid isPermaLink="false">http://warpedjavaguy.wordpress.com/?p=30#comment-276</guid>
		<description>=&gt; syntax is not java-like it breaks coherency with the rest of the lanquage.
solution might be in looking at the past.
java have modified the C syntax about arrays.
int myarray[]; in C becames int[] myarray; in java
also pointer becames implicit (-&gt; became .)
the rule mightbe
-&gt; the variable should be the last token before equal.
so 
C equivalent of int (*aFuncPtr)(int param) ; (forget throws)
should became something like
int*(int param) throws MathException aFuncPtr;

for naive user the star symbol represent the wildcard symbol replacing the name of a function.
aestically the star symbol seems a bit strange... but if you interpret it a a wildcard/replace-me-with-a-function-name, it is much better than other.
aestically I&#039;ve seen the &quot;#&quot; not so bad, but # is a comment mark.
why not the ?, it is a wildcard like *, and is already used for templates,  :
int ?(int x) throws Exception funcPtr;


another solution might be to use a reserved word, but I konw java have compatibility problems.
int function (int param) thows XException;
maybe magic anotation
int @function (int param) thows XException;
but break annotation logic. or just sugar word after star or #
int *function (int param) thows XException funPtr;
int #function (int param) thows XException funPtr;
why not the ?

also Template way seems interesting
java.lang.Function pricer;
but it is awful about return type (not clear it returns double), and cannot manage Exception throws (for me it is essential to support what is supported with Interface

my summary :
-syntax should enforce the principle that the variablename should be the last token before equal or semicolon.
- should support throws, and parameter name as Interface Method
- syntax should look like normal method declaration
- should be simple to parse
- Template does not support throws and parameter names. bad.

these are cognitive equivalents :
int *(int param) throws MathException myFunc= {return 100/param;};
int #(int param) throws MathException myFunc= {return 100/param;};
int ?(int param) throws MathException myFunc= {return 100/param;};
considering ? is used already for template, my heart goes to &#039;?&#039;, the &#039;*&#039; as a wildcard mark, then &#039;#&#039; that despite beeing a comment mark in many language is beautiful.

the invoke syntax is an orthogonal problem.
compared to C/C++, java make pointer logic disapear
Object *a=new A(); a-&gt;doIt();
became
Object a=new A(); a.doIt()
int (*funcPtr)(int param);  int result=(*funcPtr)(3)
shoudl bacame
int ?(int param) funcPtr; int result=funcPtr(3);
there is an ambiguity
if a method funcPtr(int x) exist, and also a func Pointer funcPtr; as told here java had never any such ambiguity with homonymous.

for me
int result=funcPtr.invoke(3) is not so bad... it is really java spirit where we prefer to have method that operators.

calling syntax funcPtr(3) might be acceptable as a syntax sugar when there is no ambiguity, but is it worth ? I love that in java many things stay a little verbose, showing that things are not so simple.

so I vote for .invoke(...) as it explains that func pointer is used and it is not trivial.</description>
		<content:encoded><![CDATA[<p>=&gt; syntax is not java-like it breaks coherency with the rest of the lanquage.<br />
solution might be in looking at the past.<br />
java have modified the C syntax about arrays.<br />
int myarray[]; in C becames int[] myarray; in java<br />
also pointer becames implicit (-&gt; became .)<br />
the rule mightbe<br />
-&gt; the variable should be the last token before equal.<br />
so<br />
C equivalent of int (*aFuncPtr)(int param) ; (forget throws)<br />
should became something like<br />
int*(int param) throws MathException aFuncPtr;</p>
<p>for naive user the star symbol represent the wildcard symbol replacing the name of a function.<br />
aestically the star symbol seems a bit strange&#8230; but if you interpret it a a wildcard/replace-me-with-a-function-name, it is much better than other.<br />
aestically I&#8217;ve seen the &#8220;#&#8221; not so bad, but # is a comment mark.<br />
why not the ?, it is a wildcard like *, and is already used for templates,  :<br />
int ?(int x) throws Exception funcPtr;</p>
<p>another solution might be to use a reserved word, but I konw java have compatibility problems.<br />
int function (int param) thows XException;<br />
maybe magic anotation<br />
int @function (int param) thows XException;<br />
but break annotation logic. or just sugar word after star or #<br />
int *function (int param) thows XException funPtr;<br />
int #function (int param) thows XException funPtr;<br />
why not the ?</p>
<p>also Template way seems interesting<br />
java.lang.Function pricer;<br />
but it is awful about return type (not clear it returns double), and cannot manage Exception throws (for me it is essential to support what is supported with Interface</p>
<p>my summary :<br />
-syntax should enforce the principle that the variablename should be the last token before equal or semicolon.<br />
- should support throws, and parameter name as Interface Method<br />
- syntax should look like normal method declaration<br />
- should be simple to parse<br />
- Template does not support throws and parameter names. bad.</p>
<p>these are cognitive equivalents :<br />
int *(int param) throws MathException myFunc= {return 100/param;};<br />
int #(int param) throws MathException myFunc= {return 100/param;};<br />
int ?(int param) throws MathException myFunc= {return 100/param;};<br />
considering ? is used already for template, my heart goes to &#8216;?&#8217;, the &#8216;*&#8217; as a wildcard mark, then &#8216;#&#8217; that despite beeing a comment mark in many language is beautiful.</p>
<p>the invoke syntax is an orthogonal problem.<br />
compared to C/C++, java make pointer logic disapear<br />
Object *a=new A(); a-&gt;doIt();<br />
became<br />
Object a=new A(); a.doIt()<br />
int (*funcPtr)(int param);  int result=(*funcPtr)(3)<br />
shoudl bacame<br />
int ?(int param) funcPtr; int result=funcPtr(3);<br />
there is an ambiguity<br />
if a method funcPtr(int x) exist, and also a func Pointer funcPtr; as told here java had never any such ambiguity with homonymous.</p>
<p>for me<br />
int result=funcPtr.invoke(3) is not so bad&#8230; it is really java spirit where we prefer to have method that operators.</p>
<p>calling syntax funcPtr(3) might be acceptable as a syntax sugar when there is no ambiguity, but is it worth ? I love that in java many things stay a little verbose, showing that things are not so simple.</p>
<p>so I vote for .invoke(&#8230;) as it explains that func pointer is used and it is not trivial.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xavi</title>
		<link>http://warpedjavaguy.wordpress.com/2008/02/21/pointer-syntax-for-java-closures/#comment-275</link>
		<dc:creator>Xavi</dc:creator>
		<pubDate>Tue, 04 Mar 2008 07:58:49 +0000</pubDate>
		<guid isPermaLink="false">http://warpedjavaguy.wordpress.com/?p=30#comment-275</guid>
		<description>@WarpedJavaGuy,

  I haven&#039;t explained clear enough what I wanted to say (my comment is not very clear, I should have written it better). For me it is clearer the non-pointer syntax (with &quot;=&gt;&quot;) _but_ it doesn&#039;t look like Java-ish, perhaps because Java has shared a lot of syntax with C and C doesn&#039;t have this &quot;=&gt;&quot; syntax.

  The pointer syntax may be more Java-ish but, IMHO, it is cryptic and not so clear as the &quot;=&gt;&quot; syntax. That&#039;s why I prefer the &quot;=&gt;&quot; syntax.

   For example, in the example you have written, I see much clearer the &quot;{int =&gt; boolean}&quot; syntax than the &quot;boolean* (int)&quot; one.

   Regards,

        Xavi</description>
		<content:encoded><![CDATA[<p>@WarpedJavaGuy,</p>
<p>  I haven&#8217;t explained clear enough what I wanted to say (my comment is not very clear, I should have written it better). For me it is clearer the non-pointer syntax (with &#8220;=&gt;&#8221;) _but_ it doesn&#8217;t look like Java-ish, perhaps because Java has shared a lot of syntax with C and C doesn&#8217;t have this &#8220;=&gt;&#8221; syntax.</p>
<p>  The pointer syntax may be more Java-ish but, IMHO, it is cryptic and not so clear as the &#8220;=&gt;&#8221; syntax. That&#8217;s why I prefer the &#8220;=&gt;&#8221; syntax.</p>
<p>   For example, in the example you have written, I see much clearer the &#8220;{int =&gt; boolean}&#8221; syntax than the &#8220;boolean* (int)&#8221; one.</p>
<p>   Regards,</p>
<p>        Xavi</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Talden</title>
		<link>http://warpedjavaguy.wordpress.com/2008/02/21/pointer-syntax-for-java-closures/#comment-273</link>
		<dc:creator>Talden</dc:creator>
		<pubDate>Tue, 04 Mar 2008 01:37:59 +0000</pubDate>
		<guid isPermaLink="false">http://warpedjavaguy.wordpress.com/?p=30#comment-273</guid>
		<description>Ick.

A java variable declaration (if you ignore the c-style array notation) is always:

TYPE IDENTIFIER [= INITIALISER]

I would prefer to retain the &quot;I am declaring a variable of type TYPE called IDENTIFIER whose initial value is INITIALISER&quot; structure.  I&#039;m even content to go down the FCM path to get it over what is being proposed here.

To the &quot;familiar ‘*’ symbol already used in C&quot; statement I say... Go program in C.  I always disliked the function pointer notation in C and no amount of &quot;*&quot; is going to fix that.

And when you&#039;re doing these examples please include one with exceptions and one that accepts and returns closures - as the notation needs to provide for both of these and combinations thereof.</description>
		<content:encoded><![CDATA[<p>Ick.</p>
<p>A java variable declaration (if you ignore the c-style array notation) is always:</p>
<p>TYPE IDENTIFIER [= INITIALISER]</p>
<p>I would prefer to retain the &#8220;I am declaring a variable of type TYPE called IDENTIFIER whose initial value is INITIALISER&#8221; structure.  I&#8217;m even content to go down the FCM path to get it over what is being proposed here.</p>
<p>To the &#8220;familiar ‘*’ symbol already used in C&#8221; statement I say&#8230; Go program in C.  I always disliked the function pointer notation in C and no amount of &#8220;*&#8221; is going to fix that.</p>
<p>And when you&#8217;re doing these examples please include one with exceptions and one that accepts and returns closures &#8211; as the notation needs to provide for both of these and combinations thereof.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Miller - Java Closures Death Match</title>
		<link>http://warpedjavaguy.wordpress.com/2008/02/21/pointer-syntax-for-java-closures/#comment-272</link>
		<dc:creator>Alex Miller - Java Closures Death Match</dc:creator>
		<pubDate>Mon, 03 Mar 2008 15:02:30 +0000</pubDate>
		<guid isPermaLink="false">http://warpedjavaguy.wordpress.com/?p=30#comment-272</guid>
		<description>[...] WarpedJavaGuy: Pointer Syntax for Java Closures [...]</description>
		<content:encoded><![CDATA[<p>[...] WarpedJavaGuy: Pointer Syntax for Java Closures [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: WarpedJavaGuy</title>
		<link>http://warpedjavaguy.wordpress.com/2008/02/21/pointer-syntax-for-java-closures/#comment-271</link>
		<dc:creator>WarpedJavaGuy</dc:creator>
		<pubDate>Mon, 03 Mar 2008 01:02:04 +0000</pubDate>
		<guid isPermaLink="false">http://warpedjavaguy.wordpress.com/?p=30#comment-271</guid>
		<description>Consider the following Java method signatures:

&lt;code&gt;boolean (int)
void ()
&lt;T,U&gt; T (U)
&lt;/code&gt;

Does this

&lt;code&gt;{int =&gt; boolean}
{=&gt; void}
{U =&gt; T}
&lt;/code&gt;

look more Java-ish than this?

&lt;code&gt;boolean* (int)
void* 
T* (U)
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Consider the following Java method signatures:</p>
<p><code>boolean (int)<br />
void ()<br />
&lt;T,U&gt; T (U)<br />
</code></p>
<p>Does this</p>
<p><code>{int =&gt; boolean}<br />
{=&gt; void}<br />
{U =&gt; T}<br />
</code></p>
<p>look more Java-ish than this?</p>
<p><code>boolean* (int)<br />
void*<br />
T* (U)<br />
</code></p>
]]></content:encoded>
	</item>
</channel>
</rss>