comp.lang.ada
 help / color / mirror / Atom feed
From: Anonymous Coward <nospam@nospam.com>
Subject: ADA compilers can reject types arbitrarily?
Date: Tue, 15 Nov 2005 01:16:00 GMT
Date: 2005-11-15T01:16:00+00:00	[thread overview]
Message-ID: <slrndnikpp.ish.bogus_addy@tango.mindfuq.org> (raw)
In-Reply-To: wcchdafhxo5.fsf@shell01.TheWorld.com

In article <wcchdafhxo5.fsf@shell01.TheWorld.com>, 
Robert A Duff wrote:
> 
> But surely it makes no sense for the size of an object to always be
> the same as the type's size.  Boolean'Size = 1, but you want to
> allocate Boolean variables in 32-bit registers, quite often.

Ah, yes.. I had forgotten that a types size is the same as the value
size, since I was dealing with records.  It didn't occur to me that
record type size specs should really be treated the same as they would
be w/ integers; so that makes sense.  Considering type sizes are
really value sizes, it's more clear to me now why T'size would only
specify a minimum.  I assume I can expect an O'size spec to be
absolute (O being an object).

I'm going to backpeddle on how I write interfacing records now.  I've
rep spec'd the layout of record types (even when the default layout
matches) in order to freeze the layout, in case later on the ADA
compiler changes.  Then I wrote size specs for those records to cause
a compile time error if the operational spec grows independant of the
rep spec.  

But since I technically cannot count on the size spec of a record type
to be an upper limit, I must apply a size spec to at least one object
of the rep spec'd type.  That's pretty ugly, considering objects
aren't always instantiated in the package of the type definition.  So
then I might be tempted to create dummy objects for the purpose of
protecting against partial rep specs.

It's really tempting to scrap the whole idea of writing correct ADA
code, in favor of compiler dependant but readable code.

> Jeff answered this.  By "minumim", I meant that _if_ the compiler
> accepts the rep clause, it must allocate at least that many bits for
> objects.  But "for T'Size use 0;" is still illegal for most types.

No way!  So an ADA compiler can arbitrarily decide whether to accept a
rep spec?  From the ARM, you seem to be correct:

  13.1 (13): A representation or operational item that is not
     	     supported by the implementation is illegal, or raises an
     	     exception at run time.

Amazing.  So an ADA compiler can even reject an operational spec, and
still be considered an ADA compiler.  ie. an ADA compiler can reject:

  type my_record is record
    my_integer : integer;
  end record;

I think that is gives way too much freedom to the compiler.
Technically any ADA compiler can reject my composit types, and I have
no expectation that my code will run.  I'm blown away by this.  Even
worse, the compiler doesn't have to reject the types at compile time
-- it can wait until run time to raise exceptions.  What am I missing?



  reply	other threads:[~2005-11-15  1:16 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-04  2:21 Default rep specs for record types - documented?? Anonymous Coward
2005-11-04  2:36 ` Steve
2005-11-04  4:11   ` Anonymous Coward
2005-11-04  5:30     ` Jeffrey R. Carter
2005-11-05  3:13       ` Steve
2005-11-05  4:45         ` Jeffrey R. Carter
2005-11-06 14:05           ` Steve
2005-11-06 16:08             ` Anonymous Coward
2005-11-07  7:25             ` Jeffrey R. Carter
2005-11-08 13:36               ` Steve
2005-11-14  1:12             ` Robert A Duff
2005-11-14  3:03               ` Anonymous Coward
2005-11-14 18:08                 ` Jeffrey R. Carter
2005-11-14 18:49                 ` Robert A Duff
2005-11-15  1:16                   ` Anonymous Coward [this message]
2005-11-15  2:10                     ` ADA compilers can reject types arbitrarily? tmoran
2005-11-15  3:12                     ` Robert A Duff
2005-11-15  6:44                     ` Simon Wright
2005-11-16  0:16                       ` Adaists Deny Acronym. (was: ADA compilers can reject types arbitrarily?) Björn Persson
2005-11-16  5:38                         ` Adaists Deny Acronym Simon Wright
2005-11-16  6:16                         ` Adaists Deny Acronym. (was: ADA compilers can reject types arbitrarily?) Samuel Tardieu
2005-11-15 12:43                     ` ADA compilers can reject types arbitrarily? Jeff Creem
2005-11-14 21:14                 ` Default rep specs for record types - documented?? Simon Wright
2005-11-04 13:26     ` Stephen Leake
2005-11-04 14:33       ` Marc A. Criley
2005-11-04 18:35         ` Georg Bauhaus
2005-11-04 20:07           ` Britt Snodgrass
2005-11-04 14:39       ` Stephen Leake
2005-11-04 15:27         ` Britt Snodgrass
2005-11-04 15:55           ` Lauri Ora
2005-11-04 21:42             ` Larry Kilgallen
2005-11-05  2:26             ` Anonymous Coward
2005-11-05  2:42               ` Frank J. Lhota
2005-11-05  3:27               ` Ed Falis
2005-11-05  3:55                 ` Anonymous Coward
2005-11-05  4:07                 ` Lauri Ora
2005-11-05 13:46                   ` Ed Falis
2005-11-05 10:14                 ` Stephen Leake
2005-11-04 16:52         ` Frank J. Lhota
2005-11-04 16:57           ` Frank J. Lhota
2005-11-04 23:27           ` tmoran
2005-11-05 10:25           ` Stephen Leake
2005-11-14  1:09             ` Robert A Duff
2005-11-05  3:33       ` Anonymous Coward
2005-11-05 10:34         ` Stephen Leake
2005-11-05 16:35           ` ADA/C interfaces: type representations uncontrollable in C Anonymous Coward
2005-11-05 16:49             ` Ed Falis
2005-11-05 18:24             ` tmoran
2005-11-09  2:12           ` 'Size can mean value size OR object size, depending Anonymous Coward
2005-11-09  3:27             ` Jeffrey R. Carter
2005-11-09  4:04               ` Anonymous Coward
2005-11-05 14:27         ` Default rep specs for record types - documented?? Michael Bode
2005-11-05 16:17           ` pragma convention Anonymous Coward
2005-11-06  1:07             ` Jeffrey R. Carter
2005-11-06 22:22               ` Anonymous Coward
2005-11-07  7:34                 ` Jeffrey R. Carter
2005-11-05 14:39         ` Default rep specs for record types - documented?? Martin Krischik
2005-11-04  9:40   ` Martin Dowie
2005-11-04 14:36   ` Marc A. Criley
2005-11-04 17:45 ` Martin Krischik
replies disabled

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