[comp.lang.misc] "definition" rather than assignment

othar@ernie.Berkeley.EDU (Othar Hansson) (03/21/90)

Is there any literature on taking assignment/initialization of
variables as "definition", i.e., that

mytype M = A*B;

is taken to mean that M is defined as the product of A and B, and that
changes to A will cause M to change?  Perhaps there's a
general-purpose language in which this is done (aside from
spreadsheets and special-purpose constraint languages)?  It implies
that evaluation will be more than lazy, in that evaluations get out of
date.  Other facilities are also required, such as freezing current
values (e.g., freezing B in the example above (by copying it)).

I've found a simple way to do this in C++, and it has greatly
simplified my code for one application, but I have only a few dozen
data objects to which it applies.  As my application is restricted, I
haven't had to think out the semantics of "definition" too thoroughly,
and I am wondering if I have overlooked some important problem in
applying the technique in general.

Othar Hansson
CS Division
UC Berkeley
...!ucbvax!ernie!othar
othar@ernie.berkeley.edu

gudeman@cs.arizona.edu (David Gudeman) (03/21/90)

In article  <35045@ucbvax.BERKELEY.EDU> othar@ernie.Berkeley.EDU (Othar Hansson) writes:
>
>Is there any literature on taking assignment/initialization of
>variables as "definition", i.e., that
>
>mytype M = A*B;
>
>is taken to mean that M is defined as the product of A and B, and that
>changes to A will cause M to change?  Perhaps there's a
>general-purpose language in which this is done (aside from
>spreadsheets and special-purpose constraint languages)?

Doesn't Pascal allow this?  I don't recall the exact syntax, but it
seems that

  function M:mytype begin M := A * B end;

declares M as a function of no parameters (invoked without
parenthesis) that behaves like your M.  Of course, the defining sytax
isn't quite as nice.  For an interesting developement of the general
idea (not related to Pascal) see

%A Leslie Lamport
%A Fred B. Schneider
%T ``A Uniform Approach to Aliasing and Typing''
%J JACM
%P 205-216

(Hmm... Looks like I don't have the volume number or date.  Sorry.
Maybe someone else can give a better reference.)

Lamport & Schneider describe a fairly general mechanism (actually a
constraint programming language) used as the declaration section of a
programming language that is otherwise similar to the Ada/Pascal group
of languages.
-- 
					David Gudeman
Department of Computer Science
The University of Arizona        gudeman@cs.arizona.edu
Tucson, AZ 85721                 noao!arizona!gudeman

djones@megatest.UUCP (Dave Jones) (03/27/90)

From article <35045@ucbvax.BERKELEY.EDU>, by othar@ernie.Berkeley.EDU (Othar Hansson):
> 
> Is there any literature on taking assignment/initialization of
> variables as "definition", i.e., that
> 
> mytype M = A*B;
> 
> is taken to mean that M is defined as the product of A and B, and that
> changes to A will cause M to change? 



int M()
{
  return A*B;
}


Sheesh.