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,99ab4bb580fc34cd X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: Q: access to subprogram Date: 1996/07/26 Message-ID: #1/1 X-Deja-AN: 170582774 references: <4rb9dp$qe6@news1.delphi.com> <4t4siv$bh2@goanna.cs.rmit.edu.au> <4t7dvt$cbo@mulga.cs.mu.OZ.AU> organization: The World Public Access UNIX, Brookline, MA newsgroups: comp.lang.ada Date: 1996-07-26T00:00:00+00:00 List-Id: In article <4t7dvt$cbo@mulga.cs.mu.OZ.AU>, Fergus Henderson wrote: >>However, a wrapper cannot be built for 'Accesses in the generic body >>inside the generic body. > >Can you explain in a bit more detail when this would be necessary, >and why it is not possible? It would be necessary when you say P'Access inside a generic body, and P is in that body (and not declared in the spec), and you then let the pointer escape outside the generic. This is illegal in Ada 95. I believe we're talking about full generic sharing here. Most implemtnations of sharing share *sometimes* and not other times, depending on what sort of generic it is, and what the formals are. But here, we *always* share. Well, when you call through the pointer, the called subprogram needs a pointer to the generic data -- an area of memory where variables declared in the generic package body live. There's one such are per instance. But since you have only one copy of the generic code, that code doesn't know which instance is the current one. You could generate code to do this at run time, as gcc does, but Randy said that doesn't work on some OS's. Generating code to do it at compile time is impossible, since there's only one piece of code, but many instances. If you *always* represent access-to-subprogram values with extra data telling where the generic instance data is, then it can work, but that's distributed overhead for the case where you didn't use generics. Make sense? I know nothing of Mercury, in particular how its version of generics relates to Ada's. Could you outline how you did it, and why you say it has no distributed overhead? - Bob