<div class="gmail_quote">On Wed, Nov 18, 2009 at 1:37 PM, RĂ©mi Forax <span dir="ltr"><<a href="mailto:forax@univ-mlv.fr">forax@univ-mlv.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Neal,<br>
I've just read your new proposal for lambda in Java (v0.6a).<br>
<br>
A small remarks, I think that defined @Shared as an annotation<br>
is not necessary. 'shared' as a local keyword should be better.<br></blockquote><div><br>Since it only suppresses a warning, even a context-sensitive keyword seems overkill.<br> <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Your proposal doesn't say that function types are not reified:<br></blockquote><div><br>The proposal defines function types as instances of generic interfaces. If interfaces are not reified, then it follows logically that function types are not reified and therefore need not be specified.<br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
#int(String) fun = #(String text) text.length();<br>
#int(Object) fun2 = fun; // ok, subtyping<br>
<br>
#int(String) fun3 = (#int(String))fun2; // unsafe warning.<br>
<br>
What is the reason to not use method handle to implement lambdas ?<br>
You will get reification for free.<br></blockquote><div><br>On the contrary, there are many issues preventing that. Here are two examples:<br><br>First, method handles do not have VM-verified contravariance of argument types and covariance of return types. Consequently, they cannot support function subtyping. For example, if it requires code to convert an #int(Object) into an #int(String) and the result of the conversion is not reference-equal to the original value, then how would the compiler generate code to convert an Iterable<#int(Object)> into an Iterable<#int(String)>?<br>
<br>Second, lambdas inside generic methods cannot in principle be reified if generic methods are not reified:<br><b><br style="font-family: courier new,monospace;"></b><div style="margin-left: 40px;"><b><span style="font-family: courier new,monospace;"><T> #T() makeClosure(T t)</span></b><br style="font-family: courier new,monospace;">
<b><span style="font-family: courier new,monospace;">{</span></b><br style="font-family: courier new,monospace;"><b><span style="font-family: courier new,monospace;"> return #()t; // what is the reified type of the closure here?</span></b><br style="font-family: courier new,monospace;">
<b><span style="font-family: courier new,monospace;">}</span></b><br></div><br>Cheers,<br>Neal<br></div></div>