comp.lang.ada
 help / color / mirror / Atom feed
* Re: Prefix to 'ACCESS must either statically match... But why?
@ 2003-01-27  7:12 Grein, Christoph
  2003-01-27 15:46 ` Wojtek Narczynski
  0 siblings, 1 reply; 22+ messages in thread
From: Grein, Christoph @ 2003-01-27  7:12 UTC (permalink / raw)
  To: Grein, Christoph, comp.lang.ada

> Objects of Stream_Element_Array ( 1 .. 3 ) have no bounds stored, the bounds 
are 
> known at compile time.

I should have said: Bounds are known at elaboration time. Here they are also 
known at compile time.



^ permalink raw reply	[flat|nested] 22+ messages in thread
* Re: Prefix to 'ACCESS must either statically match... But why?
@ 2003-01-30  6:20 Grein, Christoph
  0 siblings, 0 replies; 22+ messages in thread
From: Grein, Christoph @ 2003-01-30  6:20 UTC (permalink / raw)
  To: comp.lang.ada

> > No, that model is absolutely wrong!
> 
> Well, I never said I am perfect.

But are you present? Or even future?



^ permalink raw reply	[flat|nested] 22+ messages in thread
* Re: Prefix to 'ACCESS must either statically match... But why?
@ 2003-01-29 12:15 Grein, Christoph
  0 siblings, 0 replies; 22+ messages in thread
From: Grein, Christoph @ 2003-01-29 12:15 UTC (permalink / raw)
  To: comp.lang.ada

> RM 3.3.1(8): The _subtype_indication_ or full type definition of an 
> _object_declaration_ defines the nominal subtype of the object. The 
> _object_declaration_ declares an object of the type of the nominal subtype.
> 
> > AR1 : aliased Stream_Element_Array := ( 2, 4, 5 );
> 
> AR1 nominal subtype is Stream_Element_Array (<>) of type 
> Stream_Element_Array (<>)
> 
> > AR2 : aliased Stream_Element_Array ( 1 .. 3 ) := ( 2, 4, 5 );
> 
> AR2 nominal subtype is Stream_Element_Array (1 .. 3) of type 
> Stream_Element_Array (<>)
> 
> > 
> > AR1A : Stream_Element_Array_access := AR1'access;
> > 
> > -- Illegal
> > AR2A : Stream_Element_Array_access := AR2'access;
> > 
> > 
> RM/TC1 3.10.2 (24): ... The view denoted by the prefix X shall satisfy 
> the following additional requirements, presuming the expected type for 
> the X'Access is the general access type A with designated type D:
> 
> RM/TC1 3.10.2 (27/1): ...; if D is untagged, then the type view shall be 
> D, and A's designated subtype either statically match the nominal 
> subtype of the view or be discriminanted and unconstrained.
> 
> A = Stream_Element_Array_Access
> D = Stream_Element_Array (<>)
> 
> D - untagged; type of both view is Stream_Element_Array (<>) = D; and 
> A's designated subtype (Stream_Element_Array (<>)) is discriminanted and 
> unconstrained.
>
> What's wrong?

This is my exegesis. I admit, the whole theme is quite obscure...

AR1 nominal subtype Stream_Element_Array, constrained by initial value to actual 
subtype Stream_Element_Array (1 .. 3).

AR2 nominal and actual subtype Stream_Element_Array (1 .. 3).

So for AR1, nominal subtypes statically match, for AR2, they don't.
It's the nominal subtypes that have to match, not the actual ones.

See RM 3.3.1(8,9), 3.10(10), 3.10.2(27/1), 4.9.1(2).

Gnat 3.16w seems to have a problem here.



^ permalink raw reply	[flat|nested] 22+ messages in thread
* Re: Prefix to 'ACCESS must either statically match... But why?
@ 2003-01-29 11:57 Grein, Christoph
  0 siblings, 0 replies; 22+ messages in thread
From: Grein, Christoph @ 2003-01-29 11:57 UTC (permalink / raw)
  To: comp.lang.ada

> GNAT supports access to array slices with 'Unrestricted_Access, It
> will be an interesting experiment to check how it behaves on
> sub-storage unit ranges.

So I'd like to hear if and when you have results of these experiments. I'm not sure that the 
Gnat doc says it will return sensible values in this case.



^ permalink raw reply	[flat|nested] 22+ messages in thread
* Re: Prefix to 'ACCESS must either statically match... But why?
@ 2003-01-29  6:50 Grein, Christoph
  2003-01-29 11:30 ` Wojtek Narczynski
  0 siblings, 1 reply; 22+ messages in thread
From: Grein, Christoph @ 2003-01-29  6:50 UTC (permalink / raw)
  To: comp.lang.ada

> Please note that an access to array slice is by no means less safe
> than an access to the whole array. Thus I wish Ada had them.

I'm not so sure that this is possible in general. Note that the slice boundaries need no lie on storage 
unit boundaries.



^ permalink raw reply	[flat|nested] 22+ messages in thread
* Re: Prefix to 'ACCESS must either statically match... But why?
@ 2003-01-27  6:41 Grein, Christoph
  2003-01-27 18:33 ` Martin Krischik
  2003-01-27 19:05 ` Jeffrey Carter
  0 siblings, 2 replies; 22+ messages in thread
From: Grein, Christoph @ 2003-01-27  6:41 UTC (permalink / raw)
  To: comp.lang.ada

> > Could somebody please explain me why is this rule present? I find it
> > very limting. Is this because AR2 bounds are not stored with the
> > object?
> > 
> > Type Stream_Element_Array_access is access all Stream_Element_Array;
> > 
> > AR1 : aliased Stream_Element_Array := ( 2, 4, 5 );
> > AR2 : aliased Stream_Element_Array ( 1 .. 3 ) := ( 2, 4, 5 );
> > 
> > AR1A : Stream_Element_Array_access := AR1'access;
> > 
> > -- Illegal
> > AR2A : Stream_Element_Array_access := AR2'access;
> > 
> > 
> > LRM:3.10.2(27), The nominal subtype of the prefix to 'ACCESS or
> > 'UNCHECKED_ACCESS must either statically match the designated subtype
> > of the expected type or the designated subtype must be discriminated
> > and unconstrained, Continuing
> 
> Well I am a Ada-beginner myself so I might be wrong, but as far as I
> understand strictly typed languages in general "Stream_Element_Array ( 1 .. 3 
)" is a
> new anonymous type which ist not a Stream_Element_Array anymore. A bit like 
typing
> 
> Type Stream_Element_Array_AR2 is new Stream_Element_Array ( 1 .. 3 );
> AR2 : aliased Stream_Element_Array_AR2 := ( 2, 4, 5 );

No, that model is absolutely wrong!

Stream_Element_Array ( 1 .. 3 ) is a subtype of Stream_Element_Array, not a new 
type derived from it.

The difference is that Stream_Element_Array is unconstrained, 
Stream_Element_Array ( 1 .. 3 ) is constrained.

Objects of Stream_Element_Array have their bounds stored.
Objects of Stream_Element_Array ( 1 .. 3 ) have no bounds stored, the bounds are 
known at compile time.

Stream_Element_Array_access is an access type to the unconstrained (first named 
subtype) Stream_Element_Array, so its objects cannot point to objects of the 
constrained subtype.

So they do not statically match.



^ permalink raw reply	[flat|nested] 22+ messages in thread
* Prefix to 'ACCESS must either statically match... But why?
@ 2003-01-25 22:31 Wojtek Narczynski
  2003-01-26  9:57 ` Martin Krischik
  2003-01-27 19:30 ` Vadim Godunko
  0 siblings, 2 replies; 22+ messages in thread
From: Wojtek Narczynski @ 2003-01-25 22:31 UTC (permalink / raw)


Hello,

Could somebody please explain me why is this rule present? I find it
very limting. Is this because AR2 bounds are not stored with the
object?

Type Stream_Element_Array_access is access all Stream_Element_Array;

AR1 : aliased Stream_Element_Array := ( 2, 4, 5 );
AR2 : aliased Stream_Element_Array ( 1 .. 3 ) := ( 2, 4, 5 );

AR1A : Stream_Element_Array_access := AR1'access;

-- Illegal
AR2A : Stream_Element_Array_access := AR2'access;


LRM:3.10.2(27), The nominal subtype of the prefix to 'ACCESS or
'UNCHECKED_ACCESS must either statically match the designated subtype
of the expected type or the designated subtype must be discriminated
and unconstrained, Continuing


Thanks,
Wojtek



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

end of thread, other threads:[~2003-01-30  6:20 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-27  7:12 Prefix to 'ACCESS must either statically match... But why? Grein, Christoph
2003-01-27 15:46 ` Wojtek Narczynski
2003-01-27 22:32   ` James S. Rogers
2003-01-28  2:51     ` Wojtek Narczynski
2003-01-28  3:19       ` James S. Rogers
2003-01-28 12:14         ` Wojtek Narczynski
2003-01-28 14:43           ` James S. Rogers
2003-01-28 20:20             ` Wojtek Narczynski
2003-01-28 21:36               ` James S. Rogers
2003-01-29  2:09                 ` tmoran
2003-01-29 11:21                 ` Wojtek Narczynski
  -- strict thread matches above, loose matches on Subject: below --
2003-01-30  6:20 Grein, Christoph
2003-01-29 12:15 Grein, Christoph
2003-01-29 11:57 Grein, Christoph
2003-01-29  6:50 Grein, Christoph
2003-01-29 11:30 ` Wojtek Narczynski
2003-01-27  6:41 Grein, Christoph
2003-01-27 18:33 ` Martin Krischik
2003-01-27 19:05 ` Jeffrey Carter
2003-01-25 22:31 Wojtek Narczynski
2003-01-26  9:57 ` Martin Krischik
2003-01-27 19:30 ` Vadim Godunko

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