comp.lang.ada
 help / color / mirror / Atom feed
* Re: record rep on tagged record question
@ 1997-10-01  0:00 tmoran
  1997-10-01  0:00 ` Tucker Taft
  0 siblings, 1 reply; 4+ messages in thread
From: tmoran @ 1997-10-01  0:00 UTC (permalink / raw)



>Why are you writing a representation clause for a tagged record anyway?
>Are you intending to do some I/O using this type?  Have you looked at the
  No, I'm doing an API call to the OS, which has definite ideas about
how the record should be structured.  And in the real world problem this
example came from, there are discriminants involved which preclude
simply putting everything into an intermediate record, then using that
as the sole new component in the extended record.
  This is intended as a 'confirming' record rep clause, since the
compiler in question *seems* to do the expected thing, but it would be
nice to be sure.  If 'Position could be used on a type, instead of just
an object, I could make a compile time constraint error test - but it
can't.  RM 13.5.1(21) certainly leads me to believe this rep clause
should be legal.




^ permalink raw reply	[flat|nested] 4+ messages in thread
* record rep on tagged record question
@ 1997-09-23  0:00 Tom Moran
  1997-09-24  0:00 ` Matthew Heaney
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Moran @ 1997-09-23  0:00 UTC (permalink / raw)



Shouldn't this be legal Ada 95?  One of the three compilers I tried
gives a "raised CONSTRAINT_ERROR" when I try to execute it.  The
message apparently comes from the attempt to elaborate
"Picture:b.Child_Type", since neither the Ada.Text_IO in the main
program nor the one in its exception handler produces any result.
(The other two compilers both give "hi" results.)  I've checked and
Tag'Size for this compiler is 32, so an offset of 4 bytes seems
appropriate.  If I set TAG_SIZE to zero, the compiler complains that
I'm trying to overlay the tag. If I eliminate the 'for Root_Type use
record' rep clause entirely, I get "hi".
 
package b is

    TAG_SIZE : constant := 4;

    type Root_Type is tagged record
        I : Integer;
    end record;
    for Root_Type use record
        I at TAG_SIZE range 0 .. 31;
    end record;


    type Child_Type is new Root_Type with record
        J : Integer;
    end record;

end b;

with ada.exceptions;
with ada.text_io;
with b;
procedure try is
  Picture : b.Child_Type;
begin
  ada.text_io.put_line("hi");
exception
  when oops:others =>
    ada.text_io.put_line("oops:"
      & ada.exceptions.exception_information(oops));
end try;





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1997-10-01  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-10-01  0:00 record rep on tagged record question tmoran
1997-10-01  0:00 ` Tucker Taft
  -- strict thread matches above, loose matches on Subject: below --
1997-09-23  0:00 Tom Moran
1997-09-24  0:00 ` Matthew Heaney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox