TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Proportional Font
Show HTML Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
"Harbaugh, John S" <[log in to unmask]>
Reply To:
Harbaugh, John S
Date:
Thu, 20 Apr 2000 11:03:39 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (55 lines)
Hi Robin -

This is one of those Ada trivia issues that no one remembers until they bump into it a few times.

RM 4.3.3(32)  =>

NOTES

32      10      In an array_aggregate, positional notation may only be used with two or more expressions; a single expression in parentheses is interpreted as a parenthesized_expression. A named_array_aggregate, such as (1 => X), may be used to specify an array with a single component.

Not quite as hard and fast as the similar requirement for single-component records, RM 4.3.1(7).  Perhaps one of the language gurus could explain the differences between record and array aggregates.

Cheers,

        - John Harbaugh



> ----------
> From:         rreagan[SMTP:[log in to unmask]]
> Reply To:     rreagan
> Sent:         Monday, April 17, 2000 1:35 PM
> To:   [log in to unmask]
> Subject:      Constant arrays of one element.
>
> Hi,
> I am trying to write a code generator for our project and the following
> gets a compiler
> error on both GNAT v3.12 and GreenHills v1.8.9.
> ...
> type My_Array_Type is array( positive range <> ) of integer;
> ...
>    A_const_array : constant My_Array_Type := ( 16#1234# );   --<<< line 407
>
> while this does not get an error:
>
>    A_const_array : constant My_Array_Type := ( 16#1234#,  16#1234# );
>
> GHS output:
>
> Error: line 407 col 4 LRM:8.6(28), Expression has no possible
> interpretation as an expression of the expected type My_Array_Type,
> Continuing
>
> I assume that because both compilers rejected the same statement that they
> are correct, but why can't it interpret a single element array. The LRM
> 8.6(28) is not the most enlightening text :).
>
> Robin P. Reagan - Software Engineer  [log in to unmask]
> SEAKR Engineering, Inc.              v-303.649.1763x10
> 12847 East Peakview Avenue           f-303.649.1326
> Englewood, CO  80011
> "Imagination is more important than knowledge" -Albert Einstein-
>

ATOM RSS1 RSS2