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, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,21321460863e2689 X-Google-Attributes: gid103376,public From: Robert Dewar Subject: Re: Why parameter passing by copy? Date: 2000/05/27 Message-ID: <8gp70n$c6k$1@nnrp1.deja.com>#1/1 X-Deja-AN: 628027015 References: X-Http-Proxy: 1.0 x70.deja.com:80 (Squid/1.1.22) for client 205.232.38.14 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Sat May 27 19:17:52 2000 GMT X-MyDeja-Info: XMYDJUIDrobert_dewar Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.61 [en] (OS/2; I) Date: 2000-05-27T00:00:00+00:00 List-Id: In article , Dale Stanbrough wrote: > Ada requires that scalars be passed by copy. I was under the impression > that this was chosen because it was faster, but i've never seen a > rational argument for this from the Ada83 perspective of computer > hardware, nor whether such arguments still hold true for modern > processors. It needs very little "rational argument". Fortran compilers have known for a long time that it is more efficient on all common architectures to pass things by copy, and that is why Fortran allows it. Ada insisted because we decided it was not worth having implementation dependence at this point, since it is so clear that call by copy is more efficient. In a modern compiler you like to keep everything in registers where possible, so forcing call by reference would force things into memory, never mind the unnecessary overhead of the indirect reference. Parameters are typically passed in registers, so if you do things right, everything is in registers where needed, or at worst a register-register move is needed and memory references are avoided. The desire to avoid memory references becomes more and more important, so the decision to pass scalars by copy makes even MORE sense these days! The evil efficiency effects of call by reference for small items can be seen clearly in the awful SPARC ABI, where small records are required to be passed by reference. We see a significant performance degradation from this requirement, so much so that it is tempting to just ignore the ABI here. Robert Dewar Ada Core Technologies Sent via Deja.com http://www.deja.com/ Before you buy.