An Introduction to the Tingle Programming Language

Dirk van Deun, dirk at

Section 9: Access Control

The meaning of such concepts as public, private and protected members can be adapted from languages in the C++ tradition: in Tingle private means "not accessible through scoping" and protected means "not accessible through message sends", which is pretty much what they mean in C++ too. Note that private did not have to imply protected in Tingle; but it seemed to make sense to make this so anyway.

Scoped private annotations as in Scala would seem like a perfect fit for Tingle, but they are not implemented. In particular "private to the current nesting and everything lexically nested in it" seems promising (although it could use a snappier name).

By default all data is protected, i.e. unreachable from outside of the object; and all methods are public. This can be modified using:

private var ...
protected def ...
private def ...

The exact meaning of private is: not accessible through scoping from outside of the current idea or the current intersection of ideas.

The exact meaning of protected, also as implied by private, is: not accessible for message sends, and also hiding all methods "under" this one when the top method is to be determined.

There is a special form of "protected" that is ignored for direct self sends:

semiprotected def ...  // or shorter: semi def ...

Direct self sends are expressions of the syntax "self.msg(...)", as opposed to sends to other expressions that happen to evaluate to be identical to the sending object; and also the calling of top methods through scoping as described in section 8, which are self sends by another name.

Contents | Section 10: Companion Objects