Function types versus arrays
Joshua Bloch
jjb at google.com
Wed Feb 17 14:39:51 PST 2010
Neal,
I'm having a bit of trouble understanding this. I'm not endorsing any
implementation scheme, but you say that this program necessarily breaks the
type system:
*public void main(String[] args) {
#void()[] arrayOfFunction = new #void()[1];
Object[] objectArray = arrayOfFunction;
objectArray[0] = #(){ throw new IOException(); }; // **
arrayOfFunction[0].(); // invoke the function out of the array
}*
It would appear that the starred line should generate an ArrayStoreException
at runtime, as #void()(throws IOException) isn't a subtype of #void(). I
understand that it might take a sophisticated implementation to enforce
this. What am I missing?
Josh
On Wed, Feb 17, 2010 at 9:39 AM, Neal Gafter <neal at gafter.com> wrote:
> On Wed, Feb 17, 2010 at 9:25 AM, Joshua Bloch <jjb at google.com> wrote:
> > I'm not sure why you folks are worrying so much about implementation. At
> > this point, I believe we should be searching for the best spec. Then we
> can
> > worry about implementation. If we can't implement our desired spec, then
> we
> > can talk about how to weaken it.
>
> Josh-
>
> I desire a specification that is a consistent extension of the
> existing Java language. Interactions with the existing language
> specification (not implementation) necessarily implies certain
> limitations to the spec. Howard asserts otherwise, and I'm trying to
> help him see how his attempts to work around those limitations are
> fruitless.
>
> Moreover, understanding and accepting those limitations can help
> improve the form of the specification; see, for example,
> <http://gafter.blogspot.com/2010/02/syntax-option-for-project-lambda.html
> >.
>
> Cheers,
> Neal
>
More information about the lambda-dev
mailing list