Generics is involved, and generics is not capable of representing variable arity, so, if the generics say there is a return type.... there's a return type.
Void and void have basically zero relation. That's all there is to it, really. Returning no thing is just as impossible as returning 2 things. It's also not 'laziness in the compiler' - Void is not void, end of story. Trying to make the compiler sugarcoat a method that returns j.l.Void and has no return statements implies all sorts of 'under the hood magic' that javac is specifically designed NOT to do. There is an argument to be made that this design principle (the 'don't sugarcoat stuff' principle) is wrong or overzealously applied for javac, and that is an argument I might agree with, but _THAT_ is why you have to be explicit with your 'return null' here; laziness does not factor in to it. On Thursday, October 4, 2012 6:15:42 PM UTC+2, Casper Bang wrote: > > > That's exactly how I do it, and it seems clear enough to me. The >> reasoning is that null is the only valid value for variable of type >> Void, since Void is not instantiable (without trickery). >> > > Except void is, by definition, not supposed to occupy any slots on the > stack-frame, and its semantics is very different from null (any and all > types). It feels like another one of those dirty type-system duality > corners that makes erasure look like a hack. > > Then, you just do VoidMapper instead of RowMapper. (And voidMap >> instead of Map.) >> > > That's a decent way of shielding what goes on when you have a lot of > callbacks. It also composes better in a nested hierarchy of tight > one-liners (impossible with "return null;" sprinkled all over). > -- You received this message because you are subscribed to the Google Groups "Java Posse" group. To view this discussion on the web visit https://groups.google.com/d/msg/javaposse/-/LyPzgWCKgd0J. To post to this group, send email to javaposse@googlegroups.com. To unsubscribe from this group, send email to javaposse+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.