Values and objects

Albert van der Horst albert at spenarnc.xs4all.nl
Sat May 17 10:26:06 EDT 2014


In article <536decca$0$29980$c3e8da3$5496439d at news.astraweb.com>,
<SNIP>
>Personally, I don't imagine that there ever could be a language where
>variables were first class values *exactly* the same as ints, strings,
>floats etc. Otherwise, how could you tell the difference between a
>function which operated on the variable itself, and one which operated on
>the value contained by the value? The best you can do is for variables to
>be "second class" -- you can do these things to them, but you need
>special syntax or declarations to tell the compiler you're operating on
>the variable rather than the variable's value. E.g. Pascal and Algol have
>syntax for instructing the compiler when to pass a variable as a value,
>and when to pass the value. C gives you nothing.

You're talking about Algol, but there is a great distinction between
Algol60 and Algol68. Algol68 through the ref keyword goes a long
way towards making variables first class citizens.
E.g. although `` int i'' in Algol68 means practically the same as in
C, it is defined as being an abbreviation of
'ref' 'int' i = 'loc' 'int';

This means so much that i is a reference to an otherwise unnamed int
that is allocated locally. Furthermore you can't break the tie between
i and that int (because you use =, you could have used := )
Because I refers to that location you can change it by
 i:=1;
Note that the left side *must* be a reference. You can't change an
int, you can only change the content of a memory place you can refer
to.

Now you can define
'ref' 'int' pi;
pi := i;

van Wijngaarden and crue pretty much nailed it, IMO.

<SNIP>

>--
>Steven D'Aprano
>http://import-that.dreamwidth.org/

Groetjes Albert
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst




More information about the Python-list mailing list