Re: An alternative to possreps

From: Erwin <e.smout_at_myonline.be>
Date: Sat, 11 Jun 2011 07:04:20 -0700 (PDT)
Message-ID: <6eff3eab-39d7-4b75-96fe-0e0e9f0e7c16_at_s9g2000yqm.googlegroups.com>


On 9 jun, 08:28, David BL <davi..._at_iinet.net.au> wrote:
>
> I agree that update operators are an important consideration.
>
> Nevertheless I don't think type systems per se should have anything to
> do with specifying what update operators are available on variables.

Note that TTM doesn't do any such thing. D&D are quite explicit in stating that in fact there is only one update operator : assignment.

> I consider a type to be a set of values plus operators on *values* (or
> what Date calls read-only operators).

In TTM, a type is just a set of values. Nothing more. No operators involved (in the type being what it is, namely just a set of values, that is).

The fact that some operators are also needed to be able to make productive use of a type, does not mean that a type "per se" "becomes something more" than just precisely this set of values !

Nor does a type become "something more than just a set of values" as a consequence of the fact that some of those needed operators (e.g., value selectors) are so "tightly intertwined" with the type per se, that it becomes useful to introduce a single syntactic construct which declares/defines both the type itself and those related operators. Such syntactic construct are a matter of practicality toward the language user.

> Update operators can be modelled at the logical level of discourse
> using a language allowing variables to be passed by reference in some
> sense. E.g.
>
>     setmagnitude(Complex& c, Real m)
>     {
>         c := polar(m,phase(c));
>     }

If the c argument is a reference, then your assignment to this reference is invalid.

No pointers, no pass-by-reference, no variables containing variables, ... in TTM.

The TTM way is :

TYPE COMPLEX (IMAG REAL, REAL REAL);
VAR COMPLEX MYVAR=COMPLEX(0.0, 0.0);
THE_IMAG(MYVAR) := new imag value;

This latter line is syntactic shorthand for the assignment

MYVAR := COMPLEX(new imag value, THE_REAL(MYVAR));

With all that that might entail in case where the variable is a huge program-local relation variable ...

But note that there is no such thing as a "setter" operator "inside" the type, so to speak. Received on Sat Jun 11 2011 - 16:04:20 CEST

Original text of this message