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,2308afbbe4ecec0b X-Google-Attributes: gid103376,public From: "Dmitry A. Kazakov" Subject: Re: Subverting 'Access for Sub-programs Date: 1999/08/16 Message-ID: <37B804C0.361F71EE@gandalf.atm.fh-luebeck.de>#1/1 X-Deja-AN: 513349673 Content-Transfer-Encoding: 7bit References: <37A71EF1.2201@dera.gov.uk> <37A7FDE8.4F5@dera.gov.uk> <7o9vrv$qgt$1@wanadoo.fr> <7oc5ih$6mb$1@wanadoo.fr> <7oejga$28i$1@nnrp1.deja.com> <37AEF7BF.7BBC8E06@averstar.com> <7oqahu$3s0$1@nnrp1.deja.com> <37B18CF0.F50A802B@gandalf.atm.fh-luebeck.de> <7osa8r$gdq$1@nnrp1.deja.com> <37B2D220.9CAAD611@gandalf.atm.fh-luebeck.de> <7p2n3g$us9$1@nnrp1.deja.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@de.uu.net Organization: Customer of UUNET Deutschland GmbH, Dortmund, Germany Mime-Version: 1.0 NNTP-Posting-Date: 16 Aug 1999 12:26:21 GMT Newsgroups: comp.lang.ada Date: 1999-08-16T12:26:21+00:00 List-Id: Robert Dewar wrote: > Passing something by reference is completely equivalent to > passing it by pointer at the calling sequence level, and if > you are calling a C program, it could not care whether you > pass an array as an IN parameter, or pass a pointer to an > array. The same is true of procedures. Passing a procedure > by reference to foreign code would be identical to passing > it by pointer. Indeed but from implementation point of view only. From the language point of view there is a great difference. Consider this: type PointerToInt is access all Integer; ExternalRef : PointerToInt; procedure Foo (X : Integer) is begin ExternalRef := X'access; -- Illegal! end Foo; procedure Foo (X : PointerToInt) is begin ExternalRef := X; -- Legal! end Foo; Further, the first version accepts all integer varaibles in all contexts. The second one: declare Temp : aliased Integer; begin Foo (Temp'access); -- Illegal (for very good reason) end; This is, I believe, exactly what we need for subprograms too. > Yes, if you are only talking about ada-to-ada > there is some protection (although I really think that the > scheme proposed by the design team in mapping document 2 > is a lot neater, and you should review that thoroughly before > making your own suggestions). It is no matter which language is interfaced. The interface (subprogram profile) should clarify whether parameter (another subprogram) can be <'access>ed within the callee or not. When you pass an object as-is, by reference or by value, no matter (it is possible to imagine situation when a subprogram is passed by copy (:-)), then its nesting is of no importance. When you pass it by pointer, then you should know what you do and all the limitations of 'access protect unaware programmers (even if they do not want to be protected (:-)) > But in practice call back programming VERY often involves > interfacing to external code, in which case passing by > reference vs passing by pointer is identical. It always depends on WHAT the callee does. When you create a modal dialog under Windows, the dialog procedure can be passed by reference, for there is no return to caller until dialog ends. It would work exactly identical to passing by pointer with one great difference - without 'access (and its unnecessary, in this case, limitations). Best regards, Dmitry