From: Juanma Barranquero <lektu@terra.es>
Subject: Re: Assigning the value of a deferred constant?
Date: Tue, 18 Sep 2001 10:16:51 +0200
Date: 2001-09-18T10:16:51+02:00 [thread overview]
Message-ID: <c9vdqtoplu4gqjlcvkn81l97adj6obkd89@4ax.com> (raw)
In-Reply-To: 9wqp7.16899$L%5.13832570@news1.rdc1.sfba.home.com
On Mon, 17 Sep 2001 17:36:05 GMT, tmoran@acm.org wrote:
> You can't elaborate the body before you're done elaborating the
>spec, but you can elaborate a different package, including its body.
Yes, that's a solution, but still it is strange to be forced to use
another package just to initialize the constant.
After all, it is not (entirely) a matter of elaboration. If in my
example I do:
package Test is
pragma Elaborate_Body(Test);
type Byte_Order is (Little_Endian, Big_Endian);
Default_Byte_Order : Byte_Order;
end Test;
package body Test is
-- whatever
begin
-- Default_Byte_Order assigned here
end Test;
i.e., I substitute a variable for the deferred constant, it works as
expected. So I suppose that what I was really asking is why
V : T;
C : constant T := V;
for C'Address use V'Address;
does not make C a constant view of V. Surprisingly, I've done some
more tests (with GNAT 3.13p) and it *does* make C a constant view of
V... if done in the public part of the package. So:
package Test is
-- other things
Machine_Order : Byte_Order := Big_Endian;
Default_Byte_Order : constant Byte_Order := Machine_Order;
for Default_Byte_Order'Address use Machine_Order'Address;
end Test;
works (at the cost of making the variable public and so allowing the
back-door modification of Default_Byte_Order), but
package Test is
-- other things
Default_Byte_Order : constant Byte_Order;
private
Machine_Order : Byte_Order := Big_Endian;
Default_Byte_Order : constant Byte_Order := Machine_Order;
for Default_Byte_Order'Address use Machine_Order'Address;
end Test;
does not. The only differences are that Default_Byte_Order is now
deferred and Machine_Order is private. Is that an implementation
issue, or the semantics intended by the ARM? I'm pretty confused right
now :)
Thanks,
/L/e/k/t/u
next prev parent reply other threads:[~2001-09-18 8:16 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-09-15 19:36 Access types and classwide programming chris.danx
2001-09-15 20:28 ` chris.danx
2001-09-15 23:42 ` [Different Topic] Endianess? chris.danx
2001-09-16 6:22 ` Jeffrey Carter
2001-09-17 7:37 ` Juanma Barranquero
2001-09-17 7:53 ` Assigning the value of a deferred constant? Juanma Barranquero
2001-09-17 14:04 ` Ted Dennison
2001-09-17 14:36 ` Juanma Barranquero
2001-09-17 17:36 ` tmoran
2001-09-18 8:16 ` Juanma Barranquero [this message]
2001-09-18 18:40 ` Richard Riehle
2001-09-19 2:07 ` Vincent Marciante
2001-09-19 7:39 ` Juanma Barranquero
2001-09-16 6:19 ` Access types and classwide programming Jeffrey Carter
2001-09-16 13:37 ` chris.danx
2001-09-16 16:49 ` Jeffrey Carter
2001-09-16 18:24 ` David C. Hoos, Sr.
2001-09-17 6:15 ` Jeffrey Carter
2001-09-17 4:57 ` tmoran
2001-09-17 14:16 ` Ted Dennison
2001-09-16 9:32 ` tmoran
2001-09-17 9:41 ` John McCabe
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox