Re: Java 7 features
Joshua Cranmer <Pidgeot18@verizon.net> writes:
@ Closures
A lot depends on the details of how this is done.
@ Strings in switch statements
Does not really matter to me, because I rarely
come across this.
@ Operator overloading for BigDecimal
If such an extension of the syntax would be tied to a specific
class (BigDecimal), it would be ugly.
As a general language feature, it's nice to have.
@ Language-level XML support
Should not be tied to fixed classes or an implementation
or even XML. Whenever source code encounters
x = <...>
a plugable handler should be called by the compiler to convert
the "<...>" part to a Java expression. The XML-handler by Sun
would be the default.
By this, S-expressions could be embedded as well.
@ Reified generics
Now that I've written all those FAQs explaining type erasure
they want to devaluate them!!
@ Superpackages
I have not yet fully grasped this concept.
@ Removing checked exceptions
Indeed, a major part of my library code just consist
of wrapping them in RuntimeExceptions. So this would
help.
What is missing?
I want Derby (the SQL database that is part of the JDK) to
become a part of the JRE. It would help to have a default
database without any further installation.
Simplifications for common cases:
CLASS x = new CLASS( ... )
It should be allowed to abbreviate this to something
shorter like:
CLASS x = new( ... )
Similar
INTERFACE x = new( ... )
What is this? I imagine that every interface might specify
a default implemenation. For example, for java.util.List,
this would be java.util.ArrayList. Then
java.util.List<String> x = new();
would mean the same as
java.util.List<String> x = new java.util.ArrayList<String>();
Also, consider:
if( x instanceof A ){ A a =( A )x; ... }
else if( x instanceof B ){ B a =( B )x; ... }
else if( x instanceof C ){ C a =( C )x; ... }
Forget for a moment that ?instanceof? is a code smell.
Sometimes it's needed.
This could be written as
if( x instanceof A ){ ... }
else if( x instanceof B ){ ... }
else if( x instanceof C ){ ... }
if the compiler would keep track of the fact that x
in the first block is now known to have the type of A,
so that no further cast is required. (At least for
an identifier ?x? with ?final? this should hold.)