comp.lang.ada
 help / color / mirror / Atom feed
* 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; 4+ 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] 4+ messages in thread

* Re: Prefix to 'ACCESS must either statically match... But why?
  2003-01-25 22:31 Prefix to 'ACCESS must either statically match... But why? Wojtek Narczynski
@ 2003-01-26  9:57 ` Martin Krischik
  2003-01-27 19:30 ` Vadim Godunko
  1 sibling, 0 replies; 4+ messages in thread
From: Martin Krischik @ 2003-01-26  9:57 UTC (permalink / raw)


On Sat, 25 Jan 2003 14:31:17 +0000, Wojtek Narczynski wrote:

> Path:
> 	news.t-online.com!newsmm00.sul.t-online.com!newsfeed01.sul.t-online.de!t-on
> 	line.de!newsfeed.stueberl.de!logbridge.uoregon.edu!newsfeed.stanford.edu!po
> 	stnews1.google.com!not-for-mail
> Message-ID: <5ad0dd8a.0301251431.6370c6bc@posting.google.com>
> From: wojtek@power.com.pl (Wojtek Narczynski)
> Newsgroups: comp.lang.ada
> Subject: Prefix to 'ACCESS must either statically match... But why?
> Date: 25 Jan 2003 14:31:17 -0800
> Lines: 25
> Organization: http://groups.google.com/
> NNTP-Posting-Host: 212.160.20.107
> X-Trace: posting.google.com 1043533877 23863 127.0.0.1 (25 Jan 2003 22:31:17
> 	GMT)
> X-Complaints-To: groups-abuse@google.com
> NNTP-Posting-Date: 25 Jan 2003 22:31:17 GMT
> Xref: linux1.krischik.com comp.lang.ada:581
> MIME-Version: 1.0
> Content-Type: text/plain; charset=ISO-8859-1
> Content-Transfer-Encoding: 8bit
> 
> 
> 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

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 );

Hope it helps

Martin

-- 
Martin Krischik
mailto://Martin@krischik.com
http://www.ada.krischik.com




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

* Re: Prefix to 'ACCESS must either statically match... But why?
  2003-01-25 22:31 Prefix to 'ACCESS must either statically match... But why? Wojtek Narczynski
  2003-01-26  9:57 ` Martin Krischik
@ 2003-01-27 19:30 ` Vadim Godunko
  2003-01-28  4:42   ` GNAT / Aonix compiler incompatibility (Was: Prefix to 'ACCESS must either statically match... But why?) Wojtek Narczynski
  1 sibling, 1 reply; 4+ messages in thread
From: Vadim Godunko @ 2003-01-27 19:30 UTC (permalink / raw)
  To: comp.lang.ada

Wojtek Narczynski wrote:
> 
> 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;
> 

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?


Vadim Godunko




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

* GNAT / Aonix compiler incompatibility (Was: Prefix to 'ACCESS must either statically match... But why?)
  2003-01-27 19:30 ` Vadim Godunko
@ 2003-01-28  4:42   ` Wojtek Narczynski
  0 siblings, 0 replies; 4+ messages in thread
From: Wojtek Narczynski @ 2003-01-28  4:42 UTC (permalink / raw)


Vadim Godunko <vgodunko@vipmail.ru> wrote in message news:<mailman.1.1043696103.30820.comp.lang.ada@ada.eu.org>...
> 
> What's wrong?
> 

Well, I don't know... 

Could you analyze this source for compliance with RM also, please?

Regards,
Wojtek Narczynski


with ada.strings.Fixed; use ada.strings.Fixed;
with Ada.Text_IO; use Ada.Text_IO;

procedure tiny is
-- Is this code valid ?!

	type string_access is access all string;

	subtype Len_Positive is Positive range 1 .. 20;
	subtype Len_String is String ( len_Positive );
	subtype Len_String_Access is String_Access( Len_Positive );

	LS : aliased Len_String := Len_String'Length * "*";


	-- \/ This compiles with GNAT, but not with Aonix
	LSA : Len_String_Access := LS'access;


begin

	-- \/ This compiles with GNAT, but not with Aonix
	Put_Line( LSA.all );

end tiny;



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

end of thread, other threads:[~2003-01-28  4:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-25 22:31 Prefix to 'ACCESS must either statically match... But why? Wojtek Narczynski
2003-01-26  9:57 ` Martin Krischik
2003-01-27 19:30 ` Vadim Godunko
2003-01-28  4:42   ` GNAT / Aonix compiler incompatibility (Was: Prefix to 'ACCESS must either statically match... But why?) Wojtek Narczynski

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