Re: Java 7 features
On Jul 3, 8:54 am, Roedy Green <see_webs...@mindprod.com.invalid>
wrote:
On Mon, 02 Jul 2007 21:27:16 GMT, Joshua Cranmer
<Pidgeo...@verizon.net> wrote, quoted or indirectly quoted someone who
said :
@ Closures
Not keen. I think this will needlessly make code hard to understand by
the general programmer.
Not really if they are implemented a la Smalltalk.
For example:
if ( x > 0 ) { doSomething( x + 1 ); }
else { doOther( x - 1 ); }
could be written:
cond1 = #[ x > 0 ]; // #[] means delayed evaluation. cond1.eval() will
execute
cond2 = #[ fun( fun a, fun b ) { if ( cond1.eval() ) a.eval(); else
b.eval(); } ];
// since cond1 is delayed, cons1.eval() will execute.
// fun means function, fun a means a is a function.
// A function without a name is written simply fun(...parameters...)
cond2.eval( #doSomething( x + 1 ), #doOther( x - 1 ) );
// cond2 also was delayed, in order to execute,
// 2 functions need to be passed as parameters
// please note that any 2 functions could be passed
// #doSomething( x + 1 ) means pass the function instead of the
result.
@ Strings in switch statements
Not as big as deal as it once was now there are enums. The feature
will encourage inefficient code. I would like instead RANGES of ints
and enums that generate better code and code easier to maintain than
you would do manually. This is a relatively trivial extension,
requiring no JVM change. Seehttp://mindprod.com/projects/caserange.htmlfor what I a would like.
Wouldn't it be better to use RangeHashMap and closures?
@ Operator overloading for BigDecimal
fine. This can probably be done without a JVM change.
Actually the source for:
a + b
shoudl be replaced with:
a.operator_plus( b );
So it can be done trivially by the compiler.
@ Reified generics
I don't know what that means. Reify means to regard or treat (an
abstraction) as if it had concrete or material existence. Does this
mean tossing out type erasure? Generics are an embarrassment to the
language. I personally would like to start from scratch and see if
they can be made 10 time times simpler and wart-free.
What are the problems you are seeing in Generics?
It was supposed that generics fixed what C++ templates screwed, but
since I worked in C++, I felt templates were a good idea at the
beginning and then they were totally messy. It simply doesn't scale.