[Grace-core] Fwd: [important] Traits

Marco Servetto marco.servetto at gmail.com
Mon Mar 11 22:25:59 PDT 2013


Not sure to understand here:
If you can already write object Foo(...)
where Foo is a method that returns a trait, I do not see how this is
worst that using "new" in Java.

But I do believe that using new in Java is not good, since creating an
object should be perceived as a normal thing that each method can do,
not just "the special cool thing that happen when I wrote new", so
programmers should perceive construction
as simple method calls.
Now, IF you share this reason for avoiding new, that is equivalent
reason to avoid "object", but going in this direction
makes the language more "class first", object are "emanation of classes"
that "object first", classes are just a syntactic sugar for special
"singleton" objects.
Otherwise, I think we are happy that in most cases writing object
Foo(..) is a good way to create an instance, and the factory pattern
is not fundamental. Especially since one can write something like

method foo(x,y) { return .... object x(y) .... }

where the "trait" can be a parameter of a method, and thus can be used
as an instance of an abstract factory


More information about the Grace-core mailing list