"Niklas Holsti" wrote in message news:jneucmFn478U1@mid.individual.net... > On 2022-09-02 17:59, J-P. Rosen wrote: >> Le 02/09/2022 à 16:18, G.B. a écrit : >>> On 01.09.22 08:46, J-P. Rosen wrote: >>>> Le 28/08/2022 à 19:34, G.B. a écrit : >>>>> Also the convenience of being able to compare two objects for >>>>> being the same object, using "===" in some languages---out of the box! >>>>> >>>>> procedure same_object (A : T; B in out T) is >>>>> begin >>>>> what_do_i_put_here; -- ? >>>> A'Has_Same_Storage (B); >>>>> end same_object; >>>> >>>> Of course, this procedure should be a function... >>> >>> Cool, new attributes. Not very new, these were added in Ada 2012. They were considered inportant for some preconditions. >>> >>> Is the expectation that A and B occupy the same >>> bits if I pass the same X as an actual for both? >> Yes. > > > Surely only if their type (T, above) is passed by-reference? > > G.B.'s post had a later example where T is "range 1 .. 10", which is a > by-copy type, so there A and B would be separate copies of X. Agreed. Parameters of a by-copy type are separate objects from the actual objects. Parameters of a by-reference type (like tagged types) are the same objects. Parameters of types which are not specified as either may or may not be new objects. And of course, Has_Same_Storage only if true when an object is not copied. So the technique shown only certainly works for by-reference types. The compiler can copy other types when it wants, so it isn't meaningful to compare objects (only values). Randy.