Subject: Re: Encapsulation

From: Erik Ostrom <[email-masked]>
Date: Sun, 21 Nov 1993 13:55:37 -0800

> You write as if getters and setters are already a part of the language.  

They are part of the language, but not explicitly, and not in
widespread use.  (Getters in particular are very rare.)  They are part
of the language in that the language provides the permissions feature
required to enforce a certain kind of access restriction, and in that
getters and setters are a subset of the `verb' concept provided by the
language.

A getter is a verb that provides access to a property, and possibly
does other things.

A setter is a verb that allows manipulation of a property, and
possibly does other things.

By making a property's permissions "", you can enforce the use of
getter and setter verbs, rather than direct access, by everyone except
yourself.

What's been asked for, in terms of encapsulation, is a way of
disguising getters and setters as direct property manipulation.  That
is, "foo.bar" is supposed to be invisibly turned into foo:get_bar().

What I'm talking about is the fact that you can simulate
encapsulation, except for the ownership problem, but it's not
invisible; reading a property looks like foo:get_bar(), and setting a
property looks like foo:set_bar().  I don't consider it inappropriate
that calling a verb should look like calling a verb.

>						     So, these things may not
> directly save the server from crashing, but indirectly it provides a level
> of meta-"typechecking" (for lack of a better term) whose worth cannot be
> denied.

Right.  But please don't inflate their worth by making claims about
server crashes.