platform-jep to this point

Glen Peterson glen at organicdesign.org
Mon Mar 14 14:09:33 UTC 2016


I just completed the survey, then read the entire message archive for
this list.  I put most of my ideas in the survey, but I have a few
responses that I thought of after the survey (or weren't asked there).

Re: Local Variable Type Inference
http://mail.openjdk.java.net/pipermail/platform-jep-discuss/2016-March/000039.html

> 10. What do you mean by "action at a distance"?
>
> var x = "Some String";
> ...
> x = 42;

Great example.  Why not just add type inference for `final` variables?  It:
 - Uses an existing language term without changing its meaning
(doesn't break old code)
 - Prevents the above re-assignment issue entirely
 - Encourages lazy programmers to prefer immutability because the
syntax is shorter (they don't have to specify any types).


Question:
"The problem with intersection types is that in the general case, when
you have a type like C & I1 & I2 ... &  In, how do you pick the 'best'
type?" - Maurizio

Answer:
The compiler can't read the user's mind.  The user has to specify the
type they want the old fashioned way, or accept a potentially
complicated intersection type.  Please be as slow as possible to infer
Object as that's just not useful type inference in any situation
except `var x = new Object()`.  Scala infers Any (it's ultimate
super-type) too often and it's incredibly frustrating.

-- 
Glen K. Peterson
(828) 393-0081

11110 000
10 011111
10 011001
10 000010


More information about the platform-jep-discuss mailing list