Extension methods vs. Traits
Alex Blewitt
alex.blewitt at gmail.com
Fri Dec 11 01:55:43 PST 2009
Traits also suffer in Scala, because when the implementation of a
trait changes (such as bugfixing a method), the compiler has to be re-
run over all sources that use that trait. It's one of Scala's biggest
weaknesses that it is essentially a source-only compiled language.
Please don't lets follow the route of other lambda proposals and make
this more than it should be - but leave traits to a separate
implementation.
Alex
On 11 Dec 2009, at 09:45, Daniel Latrémolière wrote:
> 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