* Export instances of procedures
@ 2000-04-18 0:00 Gautier
2000-04-18 0:00 ` Vincent Marciante
2000-04-19 0:00 ` Jean-Pierre Rosen
0 siblings, 2 replies; 12+ messages in thread
From: Gautier @ 2000-04-18 0:00 UTC (permalink / raw)
Hi. GNAT 3.10-3.12 doesn't seem to want to export directly,
i.e. without "renames", instances of procedures out of a package.
Is there an Ada rule behind it ? No explanation found in the Manual.
Example:
1) This works:
package DMA is
48: procedure Read_8bit_AutoInit( linearAddressOfBuffer: unsigned_32;
length: integer );
end DMA;
package body DMA is
generic
dmaCommand: Unsigned_8;
procedure Program_DMA( linearAddressOfBuffer: unsigned_32;
length: integer );
procedure Program_DMA( linearAddressOfBuffer: unsigned_32;
length: integer ) is
...
end Program_DMA;
procedure R8AI is new Program_DMA( 16#58# );
procedure Read_8bit_AutoInit( linearAddressOfBuffer: unsigned_32;
length: integer )
renames R8AI;
end DMA;
2) But, if I put: "procedure Read_8bit_AutoInit is new Program_DMA( 16#58# );"
I get: "Read_8bit_Autoinit" conflicts with declaration at line 48
and of course: missing body for "Read_8bit_AutoInit" declared at line 48
Strange, isn't it ?
______________________________________________________
Gautier -- http://members.xoom.com/gdemont/gsoft.htm
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Export instances of procedures
2000-04-18 0:00 Export instances of procedures Gautier
@ 2000-04-18 0:00 ` Vincent Marciante
2000-04-25 0:00 ` Gautier
2000-04-19 0:00 ` Jean-Pierre Rosen
1 sibling, 1 reply; 12+ messages in thread
From: Vincent Marciante @ 2000-04-18 0:00 UTC (permalink / raw)
Gautier wrote:
>
> Hi. GNAT 3.10-3.12 doesn't seem to want to export directly,
> i.e. without "renames", instances of procedures out of a package.
> Is there an Ada rule behind it ? No explanation found in the Manual.
>
> Example:
>
> 1) This works:
>
> package DMA is
> 48: procedure Read_8bit_AutoInit( linearAddressOfBuffer: unsigned_32;
> length: integer );
> end DMA;
At this point, Read_8bit_AutoInt(...) requires a completion.
A subprogram renaming declaration (RM 8.5.4) can act as a completion but
an instantiation can't.
Other valid completions are: a body, a body stub and an import pragma.
I don't remember where in the RM a list of all valid completions is
listed.
>
> package body DMA is
> generic
> dmaCommand: Unsigned_8;
> procedure Program_DMA( linearAddressOfBuffer: unsigned_32;
> length: integer );
>
> procedure Program_DMA( linearAddressOfBuffer: unsigned_32;
> length: integer ) is
> ...
> end Program_DMA;
>
> procedure R8AI is new Program_DMA( 16#58# );
>
> procedure Read_8bit_AutoInit( linearAddressOfBuffer: unsigned_32;
> length: integer )
> renames R8AI;
> end DMA;
>
> 2) But, if I put: "procedure Read_8bit_AutoInit is new Program_DMA( 16#58# );"
> I get: "Read_8bit_Autoinit" conflicts with declaration at line 48
> and of course: missing body for "Read_8bit_AutoInit" declared at line 48
>
> Strange, isn't it ?
>
> ______________________________________________________
> Gautier -- http://members.xoom.com/gdemont/gsoft.htm
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Export instances of procedures
2000-04-18 0:00 Export instances of procedures Gautier
2000-04-18 0:00 ` Vincent Marciante
@ 2000-04-19 0:00 ` Jean-Pierre Rosen
2000-04-19 0:00 ` Pascal Obry
1 sibling, 1 reply; 12+ messages in thread
From: Jean-Pierre Rosen @ 2000-04-19 0:00 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 833 bytes --]
Gautier <gautier.demontmollin@maths.unine.ch> a �crit dans le message :
38FCBA00.992AA7A2@maths.unine.ch...
> Hi. GNAT 3.10-3.12 doesn't seem to want to export directly,
> i.e. without "renames", instances of procedures out of a package.
> Is there an Ada rule behind it ? No explanation found in the Manual.
>
> 2) But, if I put: "procedure Read_8bit_AutoInit is new
Program_DMA( 16#58# );"
> I get: "Read_8bit_Autoinit" conflicts with declaration at line 48
> and of course: missing body for "Read_8bit_AutoInit" declared at line
48
>
> Strange, isn't it ?
An instantiation is both a spec AND a body. Just remove the explicit spec,
and it will work.
--
---------------------------------------------------------
J-P. Rosen (Rosen.Adalog@wanadoo.fr)
Visit Adalog's web site at http://pro.wanadoo.fr/adalog
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Export instances of procedures
2000-04-19 0:00 ` Jean-Pierre Rosen
@ 2000-04-19 0:00 ` Pascal Obry
2000-04-19 0:00 ` Jean-Pierre Rosen
0 siblings, 1 reply; 12+ messages in thread
From: Pascal Obry @ 2000-04-19 0:00 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 787 bytes --]
Jean-Pierre Rosen a �crit dans le message <8djpm3$qef$2@wanadoo.fr>...
>An instantiation is both a spec AND a body. Just remove the explicit spec,
>and it will work.
This is not possible in his example. The spec is in a package spec (to
be exported) and he wants the body to be an instance of a generic (all
this defined in a package body).
There is no other choice than using another name and doing a "rename" I
would say.
Pascal.
--|------------------------------------------------------
--| Pascal Obry Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--| http://perso.wanadoo.fr/pascal.obry
--|
--| "The best way to travel is by means of imagination"
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Export instances of procedures
2000-04-19 0:00 ` Pascal Obry
@ 2000-04-19 0:00 ` Jean-Pierre Rosen
2000-04-19 0:00 ` Pascal Obry
0 siblings, 1 reply; 12+ messages in thread
From: Jean-Pierre Rosen @ 2000-04-19 0:00 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1079 bytes --]
Pascal Obry <p.obry@wanadoo.fr> a �crit dans le message :
8djth8$du2$1@wanadoo.fr...
>
> Jean-Pierre Rosen a �crit dans le message <8djpm3$qef$2@wanadoo.fr>...
> >An instantiation is both a spec AND a body. Just remove the explicit
spec,
> >and it will work.
>
>
> This is not possible in his example. The spec is in a package spec (to
> be exported) and he wants the body to be an instance of a generic (all
> this defined in a package body).
>
??? You can instantiate anything in a package spec. And yes, it will have
the effect of putting a body inside a spec. For example, try to instantiate
in a spec a generic package whose body has statements, like Put_Line; the
body will be executed when it is elaborated, i.e. from the middle of the
specification.
When you are a user, you can think that a spec cannot contain a body; those
who have approached a compiler would not make such a statement ;-)
--
---------------------------------------------------------
J-P. Rosen (Rosen.Adalog@wanadoo.fr)
Visit Adalog's web site at http://pro.wanadoo.fr/adalog
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Export instances of procedures
2000-04-19 0:00 ` Jean-Pierre Rosen
@ 2000-04-19 0:00 ` Pascal Obry
2000-04-20 0:00 ` Gautier
0 siblings, 1 reply; 12+ messages in thread
From: Pascal Obry @ 2000-04-19 0:00 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1284 bytes --]
Jean-Pierre Rosen a �crit dans le message <8dkjcq$skf$1@wanadoo.fr>...
>??? You can instantiate anything in a package spec. And yes, it will have
>the effect of putting a body inside a spec. For example, try to instantiate
>in a spec a generic package whose body has statements, like Put_Line; the
>body will be executed when it is elaborated, i.e. from the middle of the
>specification.
>
>When you are a user, you can think that a spec cannot contain a body; those
>who have approached a compiler would not make such a statement ;-)
You are right but my point was that this was not possible with the *supplied
code*
sample. But as you point it is always possible to have this working but here
the Program_DMA generic unit must be moved to the spec (or another spec
package). But here you have a side effect. The generic unit is now visible
to
users ! Maybe there is a nice way to handle that with some child
libraries...
Pascal.
--|------------------------------------------------------
--| Pascal Obry Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--| http://perso.wanadoo.fr/pascal.obry
--|
--| "The best way to travel is by means of imagination"
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Export instances of procedures
2000-04-19 0:00 ` Pascal Obry
@ 2000-04-20 0:00 ` Gautier
0 siblings, 0 replies; 12+ messages in thread
From: Gautier @ 2000-04-20 0:00 UTC (permalink / raw)
Pascal Obry:
> You are right but my point was that this was not possible with the *supplied
> code*
> sample. But as you point it is always possible to have this working but here
> the Program_DMA generic unit must be moved to the spec (or another spec
> package). But here you have a side effect. The generic unit is now visible
> to
> users ! Maybe there is a nice way to handle that with some child
> libraries...
You guessed well that the generic "Program_DMA" is rather of internal use!
Anyway in this context putting it into the spec. is not too dramatic : the full
DMA package (spec. & body) has now found its place inside another one.
The simple solution of putting the generic in the spec. had just not hit me...
Thank you (J.-P.) for the idea and debate!
The case appears in other pieces of code :-)
_____________________________________________
Gautier -- http://members.xoom.com/gdemont/
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Export instances of procedures
2000-04-18 0:00 ` Vincent Marciante
@ 2000-04-25 0:00 ` Gautier
2000-04-25 0:00 ` Robert Dewar
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Gautier @ 2000-04-25 0:00 UTC (permalink / raw)
Vincent Marciante wrote:
> At this point, Read_8bit_AutoInt(...) requires a completion.
> A subprogram renaming declaration (RM 8.5.4) can act as a completion but
> an instantiation can't.
Sorry for insisting on this question, but _why_ cannot the instance
be considered as complete ? Well, the generic body could depend on an
uncompletely defined type, hence the instance too. But the instance
could also be clearly complete, couldn't it ? In my code, it is!
In that case what does the "renames" bring ? Is it purely formal
or does it reflect some indirections (indirect access to the procedure) ?
NB: I have seen in the Manual many topics about completion (3.10.1, 3.11.1,
7.6.1, 9.5.2) and the one that seems the most relevant here, 8.5.4(5) but
I didn't guess the motivations behind these rules...
Maybe some wise one knows them or can decipher the Runes ? ;-)
______________________________________________________
Gautier -- http://members.xoom.com/gdemont/gsoft.htm
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Export instances of procedures
2000-04-25 0:00 ` Gautier
@ 2000-04-25 0:00 ` Robert Dewar
2000-04-26 0:00 ` Gautier
2000-04-25 0:00 ` Vincent Marciante
2000-04-26 0:00 ` Tucker Taft
2 siblings, 1 reply; 12+ messages in thread
From: Robert Dewar @ 2000-04-25 0:00 UTC (permalink / raw)
In article <3905CCCB.C48B9113@maths.unine.ch>,
Gautier <gautier.demontmollin@maths.unine.ch> wrote:
> Vincent Marciante wrote:
>
> > At this point, Read_8bit_AutoInt(...) requires a completion.
> > A subprogram renaming declaration (RM 8.5.4) can act as a
completion but
> > an instantiation can't.
>
> Sorry for insisting on this question, but _why_ cannot the
instance
> be considered as complete ?
Because that's the rule! It is absolutely clear in the RM that
an instantiation cannot act as a completion. Could the language
be designed to allow this? Sure! Is it designed that way? No!
Why, because this was considered an unnecessary complexity.
Sent via Deja.com http://www.deja.com/
Before you buy.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Export instances of procedures
2000-04-25 0:00 ` Gautier
2000-04-25 0:00 ` Robert Dewar
@ 2000-04-25 0:00 ` Vincent Marciante
2000-04-26 0:00 ` Tucker Taft
2 siblings, 0 replies; 12+ messages in thread
From: Vincent Marciante @ 2000-04-25 0:00 UTC (permalink / raw)
Gautier wrote:
>
> Vincent Marciante wrote:
>
> > At this point, Read_8bit_AutoInt(...) requires a completion.
> > A subprogram renaming declaration (RM 8.5.4) can act as a completion but
> > an instantiation can't.
>
> Sorry for insisting on this question, but _why_ cannot the instance
> be considered as complete ? Well, the generic body could depend on an
> uncompletely defined type, hence the instance too. But the instance
> could also be clearly complete, couldn't it ? In my code, it is!
> In that case what does the "renames" bring ? Is it purely formal
> or does it reflect some indirections (indirect access to the procedure) ?
I only believe that I know the answer to the last question. Some
indirection _is_ (/can be?) involved. The kind of type conformance
called "subtype conformance" is related to "renaming as body". It lets
the renaming as body be implemented by a compiler as a simple jump
instruction. I read this description in section 6.2 on page 6-4 of the
Ada 95 Rationale.
>
> NB: I have seen in the Manual many topics about completion (3.10.1, 3.11.1,
> 7.6.1, 9.5.2) and the one that seems the most relevant here, 8.5.4(5) but
The Rationale section that I mentioned also refers to the RM Section on
Conformance rules (RM95 6.3.1).
> I didn't guess the motivations behind these rules...
> Maybe some wise one knows them or can decipher the Runes ? ;-)
Yes, I do not know the underlying reasons, I just remembered from
reading the RM.
> ______________________________________________________
> Gautier -- http://members.xoom.com/gdemont/gsoft.htm
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Export instances of procedures
2000-04-25 0:00 ` Robert Dewar
@ 2000-04-26 0:00 ` Gautier
0 siblings, 0 replies; 12+ messages in thread
From: Gautier @ 2000-04-26 0:00 UTC (permalink / raw)
Robert Dewar: <<Because that's the rule!>>
OK, OK, thank you! Now I can sleep well...
_____________________________________________
Gautier -- http://members.xoom.com/gdemont/
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Export instances of procedures
2000-04-25 0:00 ` Gautier
2000-04-25 0:00 ` Robert Dewar
2000-04-25 0:00 ` Vincent Marciante
@ 2000-04-26 0:00 ` Tucker Taft
2 siblings, 0 replies; 12+ messages in thread
From: Tucker Taft @ 2000-04-26 0:00 UTC (permalink / raw)
Gautier wrote:
>
> Vincent Marciante wrote:
>
> > At this point, Read_8bit_AutoInt(...) requires a completion.
> > A subprogram renaming declaration (RM 8.5.4) can act as a completion but
> > an instantiation can't.
>
> Sorry for insisting on this question, but _why_ cannot the instance
> be considered as complete ?
This was explicitly considered during the Ada 9X design process.
The conclusion was that it might create readability problems. An
instantiation does not repeat the formal parameter part, so
matching a potentially overloaded spec with the appropriate generic
instantiation might be difficult for the human reader.
I remember there being a rather heated discussion about this issue,
but the readability-over-writability philosophy won the day,
given the availability of using renaming as a body.
> ...
> Maybe some wise one knows them or can decipher the Runes ? ;-)
You might find a discussion in minutes of some Ada 9X design
meeting, if you were able to locate them...
> ______________________________________________________
> Gautier -- http://members.xoom.com/gdemont/gsoft.htm
--
-Tucker Taft stt@averstar.com http://www.averstar.com/~stt/
Technical Director, Distributed IT Solutions (www.averstar.com/tools)
AverStar (formerly Intermetrics, Inc.) Burlington, MA USA
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2000-04-26 0:00 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-04-18 0:00 Export instances of procedures Gautier
2000-04-18 0:00 ` Vincent Marciante
2000-04-25 0:00 ` Gautier
2000-04-25 0:00 ` Robert Dewar
2000-04-26 0:00 ` Gautier
2000-04-25 0:00 ` Vincent Marciante
2000-04-26 0:00 ` Tucker Taft
2000-04-19 0:00 ` Jean-Pierre Rosen
2000-04-19 0:00 ` Pascal Obry
2000-04-19 0:00 ` Jean-Pierre Rosen
2000-04-19 0:00 ` Pascal Obry
2000-04-20 0:00 ` Gautier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox