Re: Revisit synonyms and references / typing

edA-qa wrote:
> In my previous statemtn about references and instances, I am of the 
> opinion, that in the way C2 works, the reference type has nothing to do 
> with the actual instance type. 

For clarification, an instance is characterized by a duet of type and 
locality. Locality in turn determines types of references that are 
allowed to refer to that instance. The relationship between a reference 
type and locality of an instance is at the center of the C2 referencing 
model.

An object shall only be accessed via a reference (or less safely via a 
pointer). This is also true for value-types. Consider this example:

T localT;

Here, `localT' is a const reference to a stack object T (`localT' cannot 
be rebound). Object T will be destroyed deterministically, that is, when 
the `localT' reference goes out of scope.

T& st = localT;  // error, there cannot be a synonym to a (value) type,
                  //   only to a reference.

T local^& st = localT; // st: ok, synonym to reference to local T

One may think that the indexing operator brakes the "no synonym to 
value-type" rule:

[]<T> ar[5](); // array of 5 Ts initialized with default constructor

(Continue reading)


Gmane