[squeak-dev] Re: talk on Newspeak online
Damien Cassou
damien.cassou at gmail.com
Wed May 7 09:38:42 UTC 2008
On Wed, May 7, 2008 at 10:22 AM, Igor Stasenko <siguctua at gmail.com> wrote:
> I read Gilad's blog and having some concepts which i think is
> redundant and smell like javaisms.
> For instance, i don't share the view, that all fields in class
> instance should be initialized and initialized once, by constructor
> (instance factory method).
> What about lazy initialization?
> What if superclass initializes ivar with something, then using that
> ivar during rest of initialization phase, and then at subclass
> initialization it can be overridden by another value, after done
> initializing superclass.
> I think that language shouldn't care or enforce rules aka
> 'constructors', its totally redundant to me. Developer should know
> himself, how and where initialize ivars, not in compiler/constructor.
More on constructors in newspeak:
http://gbracha.blogspot.com/2007/08/object-initialization-and-construction.html.
In Smalltalk, we have no constructor. However, when we want to
initialize data from an instance creation method we have to use
accessors:
Person class>>name: aString birthdate: aDate
^ self new
name: aString;
birthdate: aDate;
yourself
Another solution is to use a specific method like #setName:birthdate:.
However, these solutions pollute the interface of the Person class:
the developer is forced to add these methods to the public interface
of the Person class.
I believe Newspeak's solution may fix that point. What do you think?
--
Damien Cassou
Peter von der Ahé: «I'm beginning to see why Gilad wished us good
luck». (http://blogs.sun.com/ahe/entry/override_snafu)
More information about the Squeak-dev
mailing list
|