Subject: Encapsulation 2

From: [email-masked] (Gustavo Glusman)
Date: Sun, 21 Nov 1993 23:39:41 -0800

Hello again.
First I want to say I was encouraged by Pavel's "It would be more-or-less
straightforward to implement this.", and by some positive responses.
On the other hand, I was surprised to see how many people plainly didn't
understand the idea, and also by the reluctance to work on making possible
"a simple change" that would add (IMO) strength to the language.

In my first posting, I proposed that to set/get property foo, you would be
calling, in fact, :foo, if present, and with/without arguments, the only
argument being the new value for the setting.

I asked: will existing code break down? I received only positive answers,
but no examples.
When would code fail? By definition, when there is already an object
defining/inheriting a property and a verb with the same name, and if this
verb didn't conform to the model I described.
I agree that there are probably quite some such cases.

Some of the answers talked about 'getters' and 'setters'. It took me a
little more reading to understand what was meant by that. (as I said, my
computer background is long but amateurish)
But those answers talked about :get_foo and :set_foo, which I hadn't
mentioned at all... then I understood that THAT was exactly the solution.

What do I mean by this? I'm sure that a prefix can be found, such that
there's *not even one case* of an object defining/inheriting both .foo and
:prefix_foo.
I'm quite confident, too, that such a prefix can be found to be meaningful
too, not just some prefix="@%^&@%".
Maybe :input_foo/:output_foo? Just ideas.
Should this be a prefix? Maybe a suffix? Maybe both, or either?
Whatever it be, notice that such a change could be done *and* be 100%
compatible with existing code. The MOO language would be then a bit
stronger and more flexible, more true to the object-orientedness. If you
want, call that another layer of cruft. I won't.
>From the moment of the change, programmers could start building truly
encapsulated objects, and the object classes could be restructured easily,
if there's a will (and time). All of it, compatible all the time.

Notice too, I was thinking of *one* verb to do both get/set, but I agree
that it might be sounder to separate these functions.

Your comments will be very welcome, again.