[comp.lang.misc] Better Than Sliced Bread ?

phipps@garth.UUCP (Clay Phipps) (12/02/88)

"<<<" introduces lines from my original posting deleted by Walker.

In article <594@tuck.nott-cs.UUCP> 
anw@maths.nott.ac.uk (Dr A. N. Walker) writes:
>[names deleted to protect the guilty] are surprised that:
>>>	  begin int I := 0, K := 1;
>>>	  ref int Ptr := I;
>>>	  Ptr := K;
>>>	  Print (I);
>>>	  end
>prints 0 rather than 1.
>...I would have been totally astonished had it been otherwise.  
>Let's take it steadily: ...[numerous steps deleted]...
>	Ptr := K;
>		# make the place that we labelled Ptr hold instead the
>		  place that we labelled K #

Your attempt to provide an explanation at an elementary reading level
(12 1-syllable tokens and only 3 2-syllable tokens, if "Ptr" is 1 syllable)
obscures more than it reveals.

It would be far clearer and entirely accurate to suggest 
that my error was interpreting the assignation "Ptr := K"
as having the meaning (expressed "Pascallishly") "Ptr^ := K",
when it is really interpreted by Algol-68 as if it were "Ptr := ^K".

If you feel compelled to provide a really elementary explanation, 
use the notions of names, values,
locations (which are values, and abstractions of addresses), and 
containers (which have names, reside at unique locations, and hold values).
I see no advantage to be gained from contriving a notion that 
a "place" can "hold" a "place", which confuses the distinct notions of
containers and locations, not to mention native speakers of English.

The elementary (but less ambiguous) explanation of my error would be that, 
contrary to my previous interpretation,
"Ptr := K" does not transfer the value in the container named "K" 
into the container located by the value in the container named "Ptr";
what actually happens is that "Ptr := K"
transfers a value locating the container named "K"
into the container named "Ptr".

>>>The reason has to do with implicit conversions involving "ref" modes
>Not really ...

I consciously chose not to use the Algol-68 term "coercion".
I do consider the transition from what many people would call a name
to, in effect, a pointer to the container identified by that name,
to be, conceptually, a conversion, whether you wish to call it one or not.

>Well, of course [the correct semantics are] not so clear to the uninitiated;  
>but nor was the idea being expressed, and you can't expect 
>to read arbitrarily complex Algol 68 without learning it first.  

<<<...Mon Nov 28 20:24:22 PST 1988

It had been a long day.  A Monday.  
I had a vague recollection that one of the few things that I didn't like
about Algol-68 from way-back-when was its notion of references.
I hadn't read the paper in 10 years, but I thought that I would be able
to locate an example that illustrated my point.  When I saw Tanenbaum's
words [p. 174]: "this means that the program prints 0, not 1", 
I thought I had found what I was looking for.

<<<...See the paper for details.

I had hoped that I was covering myself by referring readers to the paper:

  Andrew S. Tanenbaum: "A Tutorial On Algol 68",
  _Computing Surveys_ July 1976 (vol. 8, num. 2), p. 155..190.

There is always a risk in drawing examples from a no-longer familiar
paper or book.  I took that risk.  I got burned.  
These things happen to mortals.  I have tried to look at the bright side:
there is one aspect of Algol-68 semantics that I will not soon forget.  

<<<I confess that I never had the opportunity to write code in Algol-68;...
>There are some excellent textbooks around which explain all this ....

Because you didn't recommend any textbook, 
despite my clear statement that I had never written any Algol-68 code,
it is difficult to interpret your line as anything but a put-down.

As I suggested in my original posting:
<<<...to its discredit, [Algol-68] seems to have violated the
<<<principle of "least surprise", therefore making it not quite so "clear".
<<<...Perhaps it grew on you (then again, so could C, FORTRAN, and PL/I).

I retain my lack of enthusiasm for the semantics of references in Algol-68. 

The fact that individuals can learn certain notations, concepts, or 
philosophies, and employ them successfully, 
does not necessarily make them preferable to others.
Useful work is done daily in FORTRAN and COBOL.
Just because Algol-68 reference semantics can be learned,
it does not follow that they are ideal.
-- 
[The foregoing may or may not represent the position, if any, of my employer]
 
Clay Phipps                       {ingr,pyramid,sri-unix!hplabs}!garth!phipps