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,80a7e32bed946eb9 X-Google-Attributes: gid103376,public From: dewarr@my-dejanews.com Subject: Re: access_to_constant as subprogram paramater Date: 1998/09/20 Message-ID: <6u2p9m$qe3$1@nnrp1.dejanews.com>#1/1 X-Deja-AN: 392956202 References: <6u0pmf$rvk$1@nnrp1.dejanews.com> X-Http-Proxy: 1.0 x7.dejanews.com:80 (Squid/1.1.22) for client 205.232.38.14 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Sun Sep 20 11:35:18 1998 GMT Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/2.02 (OS/2; I) Date: 1998-09-20T00:00:00+00:00 List-Id: In article , stt@houdini.camb.inmet.com (Tucker Taft) wrote: > In any case, you can just use a named access-to-constant > type in many cases, or even simpler, a plain old "IN" parameter. Very good advice. Let me state a definite rule: NEVER use an access mode parameter if you can use a normal IN or IN OUT mode parameter in its place. People have got into a LOT of trouble ignoring this rule. For example, some of the early versions of the Intermetrics bindings done for Ada 95 were peppered with incorrect uses of access parameters to model C pointers. This doesn't work because nearly all the routines expected to be able to deal with null values for the parameters, and there is of course no way to pass a null value to an access parameter (if you think you can simply use NULL as the actual, then it shows a mismatch between your conception of the language feature and the actual feature that is there -- that indeed is the worst feature of this Ada construct, it invites this mismatch!) The proper way to model a C pointer is (how amazing!) with an Ada access value for which pragma Convention (C) is given. Most likely you don't need the pragma Convention, but if you are being hyper-correct it should be there. Note that you generally cannot pass a pointer-to-unconstrained backwards and forwards to C, for the simple reason that this type corresponds to nothing at all in C. -----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum