anything like C++ references?

Adam Ruth owski at hotmail.com
Wed Jul 16 10:15:58 EDT 2003


In <Xns93BA6253C731Fduncanrcpcouk at 127.0.0.1> Duncan Booth  wrote:
> owski at hotmail.com (Adam Ruth) wrote in 
> news:f0f51c80.0307150921.7b6667e2 at posting.google.com:
> 
>> 2) C++ makes a strong distinction between the initialization operator,
>>=, and the assignment operator, =.  Both const and reference variables
>> use them differently.  To me, that's a really big violation of proper
>> 'computer science', because conceptually they're the *same* thing. 
>> But because of context, C++ makes a distinction.  Python has no such
>> distinction, initialization and assigment are always the same.
>> 
>> (This is true of all static languages with the concept of a constant,
>> and I don't really disagree with it as a valuable idiom, but it is
>> inconsistent internally, where Python is consistent.  Do any 
>> languages use a different operator for initialization?)
> 
> Yes, Algol68.
> 
> My Algol68 is more than rusty, but:
> 
> Declare a name 'pi' to represent 3.1415926, i.e. declare a constant:
> 
>     REAL pi = 3.1415926;
>     
> Declare a name 'x' to represent a local variable, and assign it a 
> value:
>
>     REF REAL x = LOC REAL;
>     x := 3.1415926;
> 
> Shorthand for the above:
> 
>    REAL x;
>    x := 3.1415926;
> 
> or even:
> 
>    REAL x := pi;
> 
> Initialisation uses '=', assignment uses ':='. Note that the constant 
> is  defined as a real and initialised with one, but the variable is a 
> reference  to a real and initialised with a storage location. The last 
> example is not  initialising x with the value, it is implicitly 
> initialising x with a  location then assigning the value into that 
> location.
>

That's interesting.  What does it use for an equality operator?




More information about the Python-list mailing list