From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ed26930bee99b420,start X-Google-Attributes: gid103376,public From: Richard Irvine Subject: Value and reference, efficiency Date: 1996/08/28 Message-ID: <322480A6.69DD@eurocontrol.fr>#1/1 X-Deja-AN: 177109606 content-type: text/plain; charset=us-ascii organization: Eurocontrol Experimental Centre, Bretigny-Sur-Orge, France mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 2.0 (X11; I; HP-UX A.09.05 9000/755) Date: 1996-08-28T00:00:00+00:00 List-Id: In Smalltalk (as far as I understand) objects maniplated in programs are in fact pointers. For example the result of anObject := anotherObject. is to have two pointers to the same piece of storage. One has to be aware of this because if one goes on to perform an operation which updates either of the objects it will appear to have updated both of them. (If this is not what is required one can do anObject := anotherObject deepCopy. in this case new storage is acquired, the data is physically copied and anObject points to the new storage.) In Ada, if the objects are records then anObject := anotherObject; will result in a copy of the data being made, so that subsequently updating one object will have no effect on the other. On the face of it one might expect that copying of references would be more efficient than copying of data. In Ada one could replicate the Smalltalk way of doing things and have objects which are in fact pointers to dynamically acquired storage and then just copy the pointer values on assignment. (Now that controlled types are available one could deallocate the storage automatically by counting references.) What I wonder is whether there is any significant performance advantage to be gained from doing this?