comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: not X'Length
Date: Thu, 15 May 2008 15:20:51 -0700 (PDT)
Date: 2008-05-15T15:20:51-07:00	[thread overview]
Message-ID: <717bf87e-b8b6-4129-8051-7bd45cf2f7b2@a9g2000prl.googlegroups.com> (raw)
In-Reply-To: 482ca195$0$6788$9b4e6d93@newsspool2.arcor-online.net

On May 15, 1:48 pm, Georg Bauhaus <see.reply...@maps.futureapps.de>
wrote:
> christoph.gr...@eurocopter.com wrote:
> > From RM 4.4 follows that this is equivalent to
>
> > if (not X'Length) in Positive then
>
> > Now Universal_Integer (X'Length is of this type) has no operators, so
> > it has to be converted to an appropriate type. This is Integer (or, to
> > be very precise, the type of Integer) in this case. But then there is
> > no "not" defined for this type. So the compiler is correct.
>
> While the compilers are correct, on the programmer's part the
> issue is not that easy to understand in general.
> You have demonstrated why this is so. Hence my original
> question about programmer expectations regarding improved
> compiler's diagnostics in this case.

You may be right that a better diagnostic would help in this specific
case.  But a programmer cannot expect a compiler to be a mind-reader.
And a compiler writer can't really go through every possible weird
combination of things to figure out what sorts of accidental trouble a
programmer could get themselves into---there are just too many
possibilities.  About all a compiler writer can do is respond to
particular situations when they get noticed.  So go ahead and file
your enhancement request, but please don't criticize the compiler (or
the vendor) next time you screw up in a different way and the compiler
can't figure out what you're trying to do.  That would be asking far
too much.

Your original post said something about expecting the compiler to
complain about "not" being applied to a universal integer.  I'm not
quite sure what your intent was, but applying "not" to a universal
integer is quite legitimate where modular types are concerned.
Something like

   (Z and not 1)

is a good way to clear a bit in Z, if Z's type is a modular type.
Maybe applying "not" to an attribute that returns a universal integer
(like "not X'Length") is less legitimate---but even then, if X'Length
is known to be a power of 2, something like (not (X'Length-1)) can be
used to yield a mask that can be used for alignment/rounding when
AND'ed with another modular value.

                                  -- Adam



  reply	other threads:[~2008-05-15 22:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-15  9:19 not X'Length Georg Bauhaus
2008-05-15  9:39 ` christoph.grein
2008-05-15 10:12   ` christoph.grein
2008-05-15 20:48   ` Georg Bauhaus
2008-05-15 22:20     ` Adam Beneschan [this message]
2008-05-16  8:04       ` Manuel Collado
2008-05-16  8:15       ` Georg Bauhaus
2008-05-16 12:52     ` Stephen Leake
replies disabled

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