comp.lang.ada
 help / color / mirror / Atom feed
* Language Lawyers help on rep_specs
@ 1995-01-03 12:49 Jeff Etrick
  1995-01-03 14:50 ` Theodore E. Dennison
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jeff Etrick @ 1995-01-03 12:49 UTC (permalink / raw)



Dear Language Lawyers,

  I have the following program which will compile and execute using one vendors
Ada95 compiler and on another vendors Ada95 spits out LRM references.

The LRM references are saying that my type Nuclear_Date_Times may not be
used in a record represenation clause due to the fact it is not a simple
static expression. Talking to the vendor about this issue I was told that the
INTEGER conversion is a function and functions are not allowed in simple
static expressions.

Looking at 4.9(6) "a function_call whose function_name .........."
tells me that static functions are allowed.

My vendor insists that my program violates the LRM, could you please
enlighten me on this. Which vendor is executing this program correctly?

Thanks for the help,

Jeff
-------

with Text_IO;

procedure test
is

  -- This type is a subtype of pre-defined INTEGER, it is used
  -- for easy use of all pre-defined packages.
  -- This is a long integer range (4 bytes storage).
  subtype Full_Integer is INTEGER range -2**31..2**31 - 1;

  HOURS_IN_DAY       : constant  := 24;
  MINUTES_IN_HOUR    : constant  := 60;
  MINUTES_IN_DAY     : constant  := HOURS_IN_DAY * MINUTES_IN_HOUR;

  -- This type defines days from December 30, 1944 through December 31, 2099.
  type Dates is new Full_Integer range -1 .. 56_613;

  -- This is a single precision floating point range.
  -- This type uses the system  defined FLOAT.
  subtype Single_Float is FLOAT digits 6;


  -- This type defines minutes, the range based upon the range
  --   declared in Dates.  This represents number of minutes
  --   from the advent of the Nuclear age (1 JAN 1945, 00:00)
  type Nuclear_Date_Times is new Full_Integer
    range (INTEGER (Dates'first) - 1) * MINUTES_IN_DAY
                .. (INTEGER (Dates'last) * MINUTES_IN_DAY) - 1;


  type Header_Record_Type
  is record
    Date_Time     : Full_Integer; --Nuclear_Date_Times;
    Id            : Full_Integer;
    x             : Full_Integer;
    y             : Full_Integer;
    Latitude      : Single_Float;
    Longitude     : Single_Float;
    Elevation     : Single_Float;
    Ltrs          : STRING(1..4);
  end record;

  for Header_Record_Type
  use record at mod 4;
    Date_Time     at  0 range 0..31;
    Id            at  4 range 0..31;
    x             at  8 range 0..31;
    y             at 12 range 0..31;
    Latitude      at 16 range 0..31;
    Longitude     at 20 range 0..31;
    Elevation     at 24 range 0..31;
    Ltrs          at 28 range 0..31;
  end record;
  for Header_Record_Type'size use 32*8;


begin
 Text_Io.Put_Line("Record Layout Test");
end test;


---------------------------------------------------------------
Jeffery R. Etrick    NET  : jeffe@fisher.CSS.GOV
ENSCO INC.           MAIL : 445 Pineda Ct.  Melbourne, Fl.  32940-7506
                     PHONE: 407-254-4122
---------------------------------------------------------------



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

* Re: Language Lawyers help on rep_specs
  1995-01-03 12:49 Language Lawyers help on rep_specs Jeff Etrick
@ 1995-01-03 14:50 ` Theodore E. Dennison
  1995-01-03 16:30   ` Tucker Taft
                     ` (2 more replies)
  1995-01-03 15:06 ` Robert Dewar
  1995-01-04 14:40 ` Norman H. Cohen
  2 siblings, 3 replies; 7+ messages in thread
From: Theodore E. Dennison @ 1995-01-03 14:50 UTC (permalink / raw)


jeffe@hathor.CSS.GOV (Jeff Etrick) wrote:
>
> 
> Dear Language Lawyers,
> 
(stuff deleted)
> The LRM references are saying that my type Nuclear_Date_Times may not be
> used in a record represenation clause due to the fact it is not a simple
> static expression. Talking to the vendor about this issue I was told that the
> INTEGER conversion is a function and functions are not allowed in simple
> static expressions.
> 
> Looking at 4.9(6) "a function_call whose function_name .........."
> tells me that static functions are allowed.
> 
> My vendor insists that my program violates the LRM, could you please
> enlighten me on this. Which vendor is executing this program correctly?

(code deleted)
>   type Dates is new Full_Integer range -1 .. 56_613;
(code deleted)
>   type Nuclear_Date_Times is new Full_Integer
>     range (INTEGER (Dates'first) - 1) * MINUTES_IN_DAY
>                 .. (INTEGER (Dates'last) * MINUTES_IN_DAY) - 1;

Your vendor is partly correct; only functions which are "operators"
may be used in static expressions. My LRM 4.9(7)  (where did you get 
6?) says:
   (e) A function call whose function name is an operator symbol 
       that denotes a predefined operator...

section 4.5 (2) defines operator symbols to be: "and", "or", "xor",
"=", "/=", "<", "+", "-", "/", etc. "INTEGER" is not in the list.

Therefore "INTEGER (Dates'first)" and "INTEGER (Dates'last)" are not 
static.

I would suggest you try either:
 o - make "Dates" a subtype of "Nuclear_Date_Times" or
 o - use "Dates'pos(Dates'first)" and "Dates'pos(Dates'last)" instead.

T.E.D.



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

* Re: Language Lawyers help on rep_specs
  1995-01-03 12:49 Language Lawyers help on rep_specs Jeff Etrick
  1995-01-03 14:50 ` Theodore E. Dennison
@ 1995-01-03 15:06 ` Robert Dewar
  1995-01-04 14:40 ` Norman H. Cohen
  2 siblings, 0 replies; 7+ messages in thread
From: Robert Dewar @ 1995-01-03 15:06 UTC (permalink / raw)


You mention in your message comparing "two vendors Ada 95 compilers". Since
no vendor has an Ada 95 compiler yet, this can't be literally the case,
so we must assume you are dealing with two prereleases of partial
implementations.

The rep clause (not spec please!) is perfectly valid, and conversions are
static in Ada 95 (but not in Ada 83).




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

* Re: Language Lawyers help on rep_specs
  1995-01-03 14:50 ` Theodore E. Dennison
@ 1995-01-03 16:30   ` Tucker Taft
  1995-01-03 18:04   ` Robert Dewar
  1995-01-03 18:07   ` Robert Dewar
  2 siblings, 0 replies; 7+ messages in thread
From: Tucker Taft @ 1995-01-03 16:30 UTC (permalink / raw)


In article <3ebo8f$jlo@theopolis.orl.mmc.com>,
Theodore E. Dennison <dennison@escmail.mmc.orl.com> wrote:
>jeffe@hathor.CSS.GOV (Jeff Etrick) wrote:

>> Dear Language Lawyers,
>> 
>(stuff deleted)
>> The LRM references are saying that my type Nuclear_Date_Times may not be
>> used in a record represenation clause due to the fact it is not a simple
>> static expression. Talking to the vendor about 
>> this issue I was told that the
>> INTEGER conversion is a function and functions are not allowed in simple
>> static expressions.
>> 
>> Looking at 4.9(6) "a function_call whose function_name .........."
>> tells me that static functions are allowed.
>> 
>> My vendor insists that my program violates the LRM, could you please
>> enlighten me on this. Which vendor is executing this program correctly?
>
>(code deleted)
>>   type Dates is new Full_Integer range -1 .. 56_613;
>(code deleted)
>>   type Nuclear_Date_Times is new Full_Integer
>>     range (INTEGER (Dates'first) - 1) * MINUTES_IN_DAY
>>                 .. (INTEGER (Dates'last) * MINUTES_IN_DAY) - 1;
>
>Your vendor is partly correct; 

No, your vendor is completely incorrect ;-).  "Integer()" is not a function
call, it is an explicit conversion.  Unlike Ada 83, explicit
conversions can be part of a static expression in Ada 95.  I suspect
they have not yet fully updated their compiler to Ada 95 rules.

> ...
>Therefore "INTEGER (Dates'first)" and "INTEGER (Dates'last)" are not 
>static.

Integer(Dates'First) and Integer(Dates'Last) are both static in Ada 95.

> ...
>T.E.D.

S. Tucker Taft   stt@inmet.com
Ada 9X Mapping/Revision Team
Intermetrics, Inc.
Cambridge, MA  02138



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

* Re: Language Lawyers help on rep_specs
  1995-01-03 14:50 ` Theodore E. Dennison
  1995-01-03 16:30   ` Tucker Taft
@ 1995-01-03 18:04   ` Robert Dewar
  1995-01-03 18:07   ` Robert Dewar
  2 siblings, 0 replies; 7+ messages in thread
From: Robert Dewar @ 1995-01-03 18:04 UTC (permalink / raw)


Ted says that Integer (x'First) is not static, and quotes something
about functions, but there is no function call involved here. Integer is
a static conversion, not a function call, and the expression
Integer (x'First) is most definitely static assuming x is a static subtype.




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

* Re: Language Lawyers help on rep_specs
  1995-01-03 14:50 ` Theodore E. Dennison
  1995-01-03 16:30   ` Tucker Taft
  1995-01-03 18:04   ` Robert Dewar
@ 1995-01-03 18:07   ` Robert Dewar
  2 siblings, 0 replies; 7+ messages in thread
From: Robert Dewar @ 1995-01-03 18:07 UTC (permalink / raw)


Incidentally, I hereby declare that since we are now in 1995, that when
I say Ada, I mean Ada 95 by default, and I will specifically say Ada 83
if that is what I mean, should I for some reason need to refer to obsolete
languages :-)




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

* Re: Language Lawyers help on rep_specs
  1995-01-03 12:49 Language Lawyers help on rep_specs Jeff Etrick
  1995-01-03 14:50 ` Theodore E. Dennison
  1995-01-03 15:06 ` Robert Dewar
@ 1995-01-04 14:40 ` Norman H. Cohen
  2 siblings, 0 replies; 7+ messages in thread
From: Norman H. Cohen @ 1995-01-04 14:40 UTC (permalink / raw)


In article <393@hathor.CSS.GOV>, jeffe@hathor.CSS.GOV (Jeff Etrick) writes: 

|> The LRM references are saying that my type Nuclear_Date_Times may not be
|> used in a record represenation clause due to the fact it is not a simple
|> static expression. Talking to the vendor about this issue I was told that the
|> INTEGER conversion is a function and functions are not allowed in simple
|> static expressions.
...
|>   subtype Full_Integer is INTEGER range -2**31..2**31 - 1;
|>
|>   HOURS_IN_DAY       : constant  := 24;
|>   MINUTES_IN_HOUR    : constant  := 60;
|>   MINUTES_IN_DAY     : constant  := HOURS_IN_DAY * MINUTES_IN_HOUR;
|>
|>   -- This type defines days from December 30, 1944 through December 31, 2099.
|>   type Dates is new Full_Integer range -1 .. 56_613;
...
|>   type Nuclear_Date_Times is new Full_Integer
|>     range (INTEGER (Dates'first) - 1) * MINUTES_IN_DAY
|>                 .. (INTEGER (Dates'last) * MINUTES_IN_DAY) - 1;

Type conversions may look like function calls, but they are not.  In any
event, RM95 4.9(9) specifically states that conversion of a static
expression (such as Dates'First or Dates'Last) to a static subtype (such
as Integer) is static.

You could have achieved the same effect more simply, however, by writing

   type Nuclear_Date_Times is
      range (Dates'First-1)*Minutes_In_Day .. Dates'Last*Minutes_In_Day-1;

(While the bounds in the range constraint of a derived-type declaration
must belong to the parent type, the bounds in an integer type declaration
can belong to any integer type, making the type conversion unnecessary.)

--
Norman H. Cohen    ncohen@watson.ibm.com



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

end of thread, other threads:[~1995-01-04 14:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-01-03 12:49 Language Lawyers help on rep_specs Jeff Etrick
1995-01-03 14:50 ` Theodore E. Dennison
1995-01-03 16:30   ` Tucker Taft
1995-01-03 18:04   ` Robert Dewar
1995-01-03 18:07   ` Robert Dewar
1995-01-03 15:06 ` Robert Dewar
1995-01-04 14:40 ` Norman H. Cohen

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