"Yannick Duch�ne (Hibou57)" wrote in message news:op.vs1xo8puule2fv@index.ici... ... > Quote from Ada 2012: > > Parameters can now be explicitly aliased, allowing parts of > function results to designate parameters and forcing > by-reference parameter passing. > >I'm not sure I've understood. What was wrong with access type parameters ? Two things: (1) need to explicitly write 'Access at every call site, when all you are doing is passing a by-reference parameter; (2) anonymous access requires a run-time accessibility level; that means that passing the wrong thing (a local object, for instance) might cause Program_Error to be raised later. This is an unnecessary hazard for the sorts of uses envisioned for aliased parameters. Aliased parameters move the check to the call site, where it almost always will succeed (there is one case involving function calls inside of allocators where it might fail, and if it does it almost always will fail at compile-time). > I don't see a reason why aliased parameters may be required (and don't > feel this can be clean). Well, why not in/out parameter for functions, as Ada 2012 allows "in out" parameters on functions. The usual use of aliased parameters is on an "in out" parameter. >things like test-and-set are common idioms, but I really can't figure why >this one in particular was required. The motivating case is to make the containers better. Ada 2012 adds the following to all of the containers: function Reference (Container : aliased in out Vector; Position : in Cursor) return Reference_Type; where Reference_Type is defined as: type Reference_Type (Element : not null access Element_Type) is private with Implicit_Dereference => Element; The aspect "Implicit_Dereference" lets you omit "Element.all" from uses of this type, so the call: My_Vector.Reference (My_Cursor).Comp := 10; is legal (presuming the element type has a component "Comp"). And another "feature" allows a form of user-defined indexing, so you actually can write: My_Vector (My_Cursor).Comp := 10; which is a big improvement over using Update_Element (which requires writing a procedure to do an in-place element update). Randy.