* Generics & Elaboration Order
@ 2000-05-08 0:00 Andrew Logue
2000-05-09 0:00 ` Robert Dewar
2000-05-09 0:00 ` Robert A Duff
0 siblings, 2 replies; 7+ messages in thread
From: Andrew Logue @ 2000-05-08 0:00 UTC (permalink / raw)
Hello,
I need help to instantiate a generic package with an actual parameter whose
value must be determined at run-time.
Please take a peek at the following pseudo-code:
package body main is
Actual_Parameter : Boolean := False;
package New_Pack is new Generic_Package( Parameter => Actual_Parameter );
begin -- package elaboration code
if some_package.embedded_computer_type = some_package.type_A then
Actual_Parameter := True;
else
Actual_Parameter := False;
end if;
end main;
Given the above code, and the embedded computer type is type_A, will
New_Pack be instantiated with an Actual_Parameter value of True or False?
i.e. does the code in package body execute before the generic is
instantiated?
Thank you for your feedback,
Andrew Logue,
Computing Devices Canada.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Generics & Elaboration Order
2000-05-08 0:00 Generics & Elaboration Order Andrew Logue
@ 2000-05-09 0:00 ` Robert Dewar
2000-05-18 0:00 ` ANTHONY GAIR
2000-05-09 0:00 ` Robert A Duff
1 sibling, 1 reply; 7+ messages in thread
From: Robert Dewar @ 2000-05-09 0:00 UTC (permalink / raw)
In article <8F2E930FAandrewloguecdcgycom@142.77.1.194>,
nospam.andrew.logue@cdcgy.com (Andrew Logue) wrote:
> i.e. does the code in package body execute before the generic
> is instantiated?
No, certainly not
Generally the linear elaboration semantics of Ada mean that
an expression is evaluated when you come to it. There are
very few exceptions to this rule (default expressions in
specs are one case, generic templates are the other).
Sent via Deja.com http://www.deja.com/
Before you buy.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Generics & Elaboration Order
2000-05-08 0:00 Generics & Elaboration Order Andrew Logue
2000-05-09 0:00 ` Robert Dewar
@ 2000-05-09 0:00 ` Robert A Duff
1 sibling, 0 replies; 7+ messages in thread
From: Robert A Duff @ 2000-05-09 0:00 UTC (permalink / raw)
nospam.andrew.logue@cdcgy.com (Andrew Logue) writes:
> package body main is
>
> Actual_Parameter : Boolean := False;
> package New_Pack is new Generic_Package( Parameter => Actual_Parameter );
>
> begin -- package elaboration code
>
> if some_package.embedded_computer_type = some_package.type_A then
>
> Actual_Parameter := True;
>
> else
>
> Actual_Parameter := False;
>
> end if;
>
>
> end main;
>
> Given the above code, and the embedded computer type is type_A, will
> New_Pack be instantiated with an Actual_Parameter value of True or False?
I presume Parameter is mode 'in'. In that case, False is passed.
If Parameter is mode 'in out', then it's like a renaming,
but I don't think that's what you're talking about.
> i.e. does the code in package body execute before the generic is
> instantiated?
No.
- Bob
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2000-05-21 0:00 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-05-08 0:00 Generics & Elaboration Order Andrew Logue
2000-05-09 0:00 ` Robert Dewar
2000-05-18 0:00 ` ANTHONY GAIR
2000-05-18 0:00 ` Robert A Duff
2000-05-19 0:00 ` ANTHONY GAIR
2000-05-21 0:00 ` Robert Dewar
2000-05-09 0:00 ` Robert A Duff
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox