+1 to that - I think a lot of people seem to think that a closure is just a shorter syntax for an anonymous class, which is not the case.
At the moment it’s not clear whether what they’re proposing actually qualifies as a “closure” or not, though; plenty of folks are, in fact, pushing for no more than a simpler anonymous class syntax, and I really have to take issue with calling that a closure, since the more powerful things you can do with closures are not possible if that’s all we get.
And FWIW, none of this stuff is even remotely new, even in OO languages, so I don’t really buy the complaint that Java is trying to “keep up” or anything like that. It’s more that computing is necessarily pushing towards parallelism, and functional style becomes vastly more important there, so Java has to make some concessions in that direction to remain viable. Without a serious effort to ease parallel programming, Java will fall further behind productivity-wise as we need to scale horizontally, which would be a shame. Real closures would allow a lot of the important logic and optimization to be put into easy to use libraries instead of the rather low level concurrency support we have today, and I think that will be a major win if it’s done right.
The current syntax seems kind of bizarre, though, and some of the discussions on the mailing lists make me worry that this implementation will be pretty seriously crippled, so I don’t know how I feel about the addition overall…I’ll have to see how the finalized proposal looks, I think.
Cas, as far as automatic conversions, Scala does lets you do that (basically, just write a conversion function and mark it implicit, and then it Just Works), and it is extremely convenient - it makes dealing with unit-ful values a breeze, whereas it’s a major pain in the ass in Java because of the explicit conversions all over the place.
It would never make it into Java, though, because people in the Java community are psychotically paranoid about potential abuse of language features, and this one actually has some real potential for confusion and bug-hiding.
(Roquen already correctly noted that division requires a unique inverse, which is definitely true)
Sure, you can do anything you want, but it wouldn’t necessarily have all the properties you might want from those operators, or a particularly natural meaning. With vectors in N dimensions, there’s the inner (dot) product, which returns a scalar, and an outer product, which returns an N-dimensional matrix in the obvious way. Neither of these permit division as the inverse, since they don’t create vectors. If you want vector*vector = vector, then in 3D we usually use the dual of the exterior or wedge product of 2 vectors (which boils down to the cross product), but this doesn’t generalize to other dimensionalities, since you need N-1 vectors as inputs to make the dual of a wedge come out as a vector (Google “exterior algebra” if you care what any of that means). In 2D you can use complex multiplication, but that may or may not let you do something useful, depending on context.
Usually people define * and / between vectors and numbers, but not between vectors themselves, when operator overloading. If you’re dealing with complex numbers, you define them all. Matrices get * defined, but oftentimes not /, because the operation of inverting a matrix can fail sometimes and it’s usually best not to hide that by making it look like regular old division.
This is pretty much exactly how mathematicians use the objects and symbols as well, at least for these simple cases, except that sometimes it’s implicit that if you multiply two vectors you’re taking the inner product, which is a lot more clear in written math because you use a dot for multiplication anyways.
Personally, I’d love to see Java get some built in primitives (preferably stack-allocated and immutable) for vectors, matrices, and complex numbers, with these overloadings baked in; if that happened, I wouldn’t care about operator overloading one bit, though I’d also like the big/arb. precision number classes to get the same treatment. I can’t come up with many other compelling or common use cases for operator overloading that make sense, but those ones cause a lot of pain if you work in areas that require them…