comp.lang.ada
 help / color / mirror / Atom feed
* Representation clause in records?
@ 1999-02-05  0:00 Corey Minyard
  1999-02-05  0:00 ` Keith Thompson
  0 siblings, 1 reply; 4+ messages in thread
From: Corey Minyard @ 1999-02-05  0:00 UTC (permalink / raw)


In section 3.8 of the RM we see:

(1)   A record object is a composite object consisting of named
      components. The value of a record object is a composite value
      consisting of the values of the components.

Syntax

(2)   record_type_definition ::= [[abstract] tagged] [limited] record_definition
(3)   record_definition ::=
           record
              component_list
           end record
         | null record
(4)   component_list ::=
             component_item {component_item}
          | {component_item} variant_part
          |  null;
(5)   component_item ::= component_declaration | representation_clause
(6)   component_declaration ::=
          defining_identifier_list : component_definition [:= default_expression];

I am playing around with ASIS and I was to the point of handling the
representation clause here.  My question is: What is the representation
clause specified in (5)?  I have it from a reliable source that the
following is not legal:

package Test1 is

   type T1 is record
      A : Integer;
      for A'Size use 32;
   end record;

end Test1;

So what is the RM saying here?  ASIS seems to allow something of this
affect, but I didn't find any text in the RM section that talked about
this construct.

-- 
Corey Minyard                   Internet:  minyard@acm.org
  Work: minyard@nortelnetworks.com  UUCP:  minyard@wf-rch.cirr.com




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

* Re: Representation clause in records?
  1999-02-05  0:00 Representation clause in records? Corey Minyard
@ 1999-02-05  0:00 ` Keith Thompson
  1999-02-06  0:00   ` Steven Hovater
  0 siblings, 1 reply; 4+ messages in thread
From: Keith Thompson @ 1999-02-05  0:00 UTC (permalink / raw)


Corey Minyard <minyard@acm.org> writes:
[...]
> (5)   component_item ::= component_declaration | representation_clause
> (6)   component_declaration ::=
>           defining_identifier_list : component_definition [:= default_expression];
> 
> I am playing around with ASIS and I was to the point of handling the
> representation clause here.  My question is: What is the representation
> clause specified in (5)?

If I'm not mistaken, the grammar permits a representation clause here
only to allow for the possibility of implementation-defined
representation clauses.  There are no language-defined rep clauses
that can appear in place of a component declaration -- and I don't
think any current implementations support such clauses.

If this is correct, you can probably get away with ignoring rep
clauses within record declarations.  If it isn't, I'm sure I can count
on someone to point it out.

-- 
Keith Thompson (The_Other_Keith) kst@cts.com <*>
San Diego, California, USA <http://www.ghoti.net/~kst>
Will write code for food.




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

* Re: Representation clause in records?
  1999-02-05  0:00 ` Keith Thompson
@ 1999-02-06  0:00   ` Steven Hovater
  1999-02-06  0:00     ` Keith Thompson
  0 siblings, 1 reply; 4+ messages in thread
From: Steven Hovater @ 1999-02-06  0:00 UTC (permalink / raw)


The only rep spec I"ve seen is an alignment clause at the beginning of the record,
e.g. (best I can recall...)
type foo is record
   for foo'address use at mod 32;
   begin
     blah : integer16;
     more_blah : integer16;
end record;

cheers,
Steve

Keith Thompson wrote:

> Corey Minyard <minyard@acm.org> writes:
> [...]
> > (5)   component_item ::= component_declaration | representation_clause
> > (6)   component_declaration ::=
> >           defining_identifier_list : component_definition [:= default_expression];
> >
> > I am playing around with ASIS and I was to the point of handling the
> > representation clause here.  My question is: What is the representation
> > clause specified in (5)?
>
> If I'm not mistaken, the grammar permits a representation clause here
> only to allow for the possibility of implementation-defined
> representation clauses.  There are no language-defined rep clauses
> that can appear in place of a component declaration -- and I don't
> think any current implementations support such clauses.
>
> If this is correct, you can probably get away with ignoring rep
> clauses within record declarations.  If it isn't, I'm sure I can count
> on someone to point it out.
>
> --
> Keith Thompson (The_Other_Keith) kst@cts.com <*>
> San Diego, California, USA <http://www.ghoti.net/~kst>
> Will write code for food.

--
Steven Hovater
svh@rational.com
Software Engineering Consultant
Phone/fax:781-676-2565/2500
Rational Software
Pager: 888-906-2209
83 Hartwell Ave, Lexington, MA                                             Amateur
radio: AA1YH






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

* Re: Representation clause in records?
  1999-02-06  0:00   ` Steven Hovater
@ 1999-02-06  0:00     ` Keith Thompson
  0 siblings, 0 replies; 4+ messages in thread
From: Keith Thompson @ 1999-02-06  0:00 UTC (permalink / raw)


Steven Hovater <nh-ho@mediaone.net> writes:
> The only rep spec I"ve seen is an alignment clause at the beginning
> of the record, e.g. (best I can recall...)
> type foo is record
>    for foo'address use at mod 32;
>    begin
>      blah : integer16;
>      more_blah : integer16;
> end record;

No, the syntax you're thinking of is:

   type Foo is
      record
         Blah      : Integer16;
         More_Blah : Integer16;
      end record;
   for Foo use
      record at mod 4;			-- Storage units, not bits
         Blah      at 0 range 0 .. 15;  -- (the component clauses
         More_Blah at 2 range 0 .. 15;  -- are optional)
      end record;

The alignment clause is within the record representation clause, not
the record type declaration.

(You can also specify the alignment with "for Foo'Alignment use 4;".)

-- 
Keith Thompson (The_Other_Keith) kst@cts.com <*>
San Diego, California, USA <http://www.ghoti.net/~kst>
Will write code for food.




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

end of thread, other threads:[~1999-02-06  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-02-05  0:00 Representation clause in records? Corey Minyard
1999-02-05  0:00 ` Keith Thompson
1999-02-06  0:00   ` Steven Hovater
1999-02-06  0:00     ` Keith Thompson

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