Need feedback on simple idea

Richard A. O'Keefe ok at cs.otago.ac.nz
Fri Apr 11 01:44:29 UTC 2003


Stephane Ducasse <ducasse at iam.unibe.ch> wrote:
	remove direct access to instance variables a la self
	
*NO*.

	Pros:
		simplicity/uniformity no distinction between state and
		methods.
	
Simplicity of the *language* is not what matters,
but simplicity of *use*.  We could make a really really simple
language.  For example, it is possible to have a computer instruction
set with just one instruction.  (I don't remember what the instruction
is exactly, something like "subtract X from Y and jump to L if the
result is negative".)  That's simple to *define* but not at all
simple to *use*.

I see no benefit _as a programmer_ here.

	Cons:
		no private iv anymore anymore 

For me this is a *HUGE* loss.  It is important to me that I can
change my mind repeatedly about what the instance variables are
and what they are called and when they are initialised without
ANY visible changes to the interface.

You have forgotten another serious loss:
    In Smalltalk at the moment, you have have an instance variable
    snarkleFest and access methods snarkleFest and snarkleFest:
    and THOSE METHODS ARE NOT LIMITED TO FETCHING AND STORING THE
    INSTANCE VARIABLE.  The "fetch" method may do lazy initialisation.
    The "store" method may check argument acceptability.  With your
    scheme, if I wanted to provide such access methods, then I would
    have to call the instance variable something else, maybe
    snarkleFestIfIWantSelfIKnowWhereToFindIt, and then I get two access
    methods I _don't_ want that bypass my careful checking.

		(except if we try to have
		a clever schema that lets the programmer writing self x
		while the byte code remove the send) with this schema we
		could have private instance variables but be forced to
		used a normal method to make public an accessor.

Frankly, I completely fail to see how being forced to write
"self snarkleFest" and "self snarkleFest: x" makes my life
in any way simpler than writing just "snarkleFest" and "snarkleFest := x".

Of course, Self *doesn't* make my life harder that way, because of its
"implicit self".  But then, if I want Self, I know where to find it.
One of the reasons I use Smalltalk is that it *isn't* Self.



More information about the Squeak-dev mailing list