Traits with pool vars?
stéphane ducasse
ducasse at iam.unibe.ch
Thu Apr 7 11:59:01 UTC 2005
> I love the way traits separate method from class.
:) me too
> Traits do not know the ultimate class, so they cannot reference
> instvars.
> Traits do know Smalltalk, so they can reference global variables and
> are not quite stateless.
> I have occasion to experiment with "regional variables" and want to
> use pool vars for this.
> Ar a first glance, it seems simple to let traits access pool vars.
>
> Does this violently violate the ideas behind traits?
Interesting question.
I will have to digest it.
But without too much thinking I would say that as soon as you only have
the same
global space this should not be a problem. However now this could mean
that
you would need a kind of requirement for dependency with the pool.
Because you could load a PoolReferingTrait into a system not having
this pool
and then yoru code would not be working.
So my solution would be to:
do not access pool in traits
use a required methods instead
and in the class provide a method to access to the pool
this way the class has the responsibility to access/provide state and
traits just use
or express requirement and are not polluted with state.
Stef
More information about the Squeak-dev
mailing list
|