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,60dd4fe7723c0ef X-Google-Attributes: gid103376,public From: Robert Dewar Subject: Re: Ada Core Technologies announces GNATCOM Date: 2000/04/12 Message-ID: <8d2csa$1hm$1@nnrp1.deja.com>#1/1 X-Deja-AN: 610280225 References: <8coc5e$do2$1@nnrp1.deja.com> <8d0ru2$arc$1@nnrp1.deja.com> <8d1paa$n0n4@ftp.kvaerner.com> X-Http-Proxy: 1.0 x39.deja.com:80 (Squid/1.1.22) for client 205.232.38.14 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Wed Apr 12 17:48:01 2000 GMT X-MyDeja-Info: XMYDJUIDrobert_dewar Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.61 [en] (OS/2; I) Date: 2000-04-12T00:00:00+00:00 List-Id: In article <8d1paa$n0n4@ftp.kvaerner.com>, "Tarjei T. Jensen" wrote: > It is not neccessarily all bad. I would not be surprised if > there exists a C compilers which would pass a struct as value > if it is smaller than 4 or 8 bytes and pass them by reference > if they are bigger. I seem to remember having read > about such a convention. You are confusing pass by reference (which is NEVER used in C calling sequences) and pass by address (which is often used in C calling sequences for large values, in fact one cannot think of any other approach, the typical thing being to pass the address of a copy. But that's NOT what the Ada RM requires, it requires that it be passed by reference, which has totally different semantics. Indeed the quoted paragraph above is EXACTLY the confusion that caused this unsupportable design of the C_Pass_By_COpy pragma in the first place. There is a big difference between call by reference, where a modification to the parameter in the C routine will cause a change to the original, and call by address of a copy, which will not have this effect. Yes, its confusing, and this confusion is what lead to the mistake a) in the RM, which requires IN records to be passed by reference instead of value. b) in the design of the C_Pass_By_Copy pragma, which extends the confusion. Unfortunately, there is nothing much we can do at this stage except live with a little mess here, luckily cases where C programmers pass records as parameters (as opposed to pointers to records) are rare. Sent via Deja.com http://www.deja.com/ Before you buy.