Extension methods vs. Traits

Daniel Latrémolière daniel.latremoliere at gmail.com
Fri Dec 11 01:45:19 PST 2009


I would like to understand the final paragraph of the proposal where you 
are saying that the traits are much more significant change than 
extension methods to the language and VM.

The VM doesn't need to implements traits. The compiler can transform one 
trait in one interface with abstract methods and declaration-sites for 
non-abstract methods and one anonymous class with the non-abstract 
methods coming from the trait and referenced in the interface by 
declaration-sites.
Then I don't think traits are a bigger change in VM than extension 
methods, because this can be only a language feature implemented by 
compiler using your declaration-site in bytecode.

For the language, I think traits are much more readable, because code is 
local, and doesn't not ask to follow the delegate to the static method 
in another class file. I think traits are reusing much more current Java 
language (method syntax) and doesn't introduce a new construct like 
declaration-site extension methods. But, I have not studied all possible 
effects in Java language.

Thanks for the explanations,
Daniel Latrémolière.



More information about the lambda-dev mailing list