comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@gnat.com
Subject: Re: simple question - how to emulate void * ?
Date: 1998/10/25
Date: 1998-10-25T00:00:00+00:00	[thread overview]
Message-ID: <7101bo$2sn$1@nnrp1.dejanews.com> (raw)
In-Reply-To: 70q89d$io1$1@nnrp1.dejanews.com

In article <70q89d$io1$1@nnrp1.dejanews.com>,
  dennison@telepath.com wrote:
> In article <1104_909142646@DZOG-CHEN>,
>   falis@ma.aonix.com (Ed Falis) wrote:
> > In OA, both System and System.Storage_Units declare "+" operators with
Address
> and Integer or Storage_Offset respectively.  Since there are use clauses
> > for both units, the compiler doesn't know how to interpret the numeric
literal
> "1" on the right hand side of the expression.
> >
> > So, eliminate one of the use clauses, or qualify the literal, e.g.
Integer'(1)
> or Storage_Offset'(1), and the code will compile and execute.
> >
>
> One more poor soul burned by the evil "use" clause...


That does not seem exactly fair in this case. It is a mistake in an Ada 95
compiler to provide address arithmetic in System. Yes, some compilers do
this for compatibility with implementation dependent additions to their
System packages for Ada 83, but it is a huge pain for Ada 95 programmers.

We ran across this with the DEC version of System which also supplies address
arithmetic (and lots of other stuff) in their System, and it definitely
inteferes with many existing programs. The danger here is not in using a
USE clause per se, but in the assumption that "use System" only gets you
the stuff you see in the RM. Unfortunately, that is not necessarily the
case, since implementors are allowed to add anything they like to System.

In GNAT, the standard version of System that you get without doing anything
special is the one in the RM. If you need an extended version of System with
non-standard extensions, then you can use the GNAT pragma Extend_System,
naming a package that provides the extensions. We distribute a standard
package System.Aux_DEC that provides the DEC Ada 83 extensions, but
additional extensions can be provided.

It would for example be possible to provide a package that added the OA
extensions, and this is probably easy to do. We just haven't done it because
there hasn't been any demand for this (our customers are typically writing
new Ada 95 programs, or porting legacy code from other than Alsys systems,
or porting standard Ada code that does not use these extensions) so the
issue has not arisen. Note that it is definitely good Ada practice NOT
to use System dependent extensions in Ada programs.

For those not allergic to use clauses, it is a bit of a pity not to allow
yourself to "use system", but with compilers around that add
implementation dependent stuff to System, it may cause difficulties.

Note that Ada is carefully designed so that the "evil" effects of using USE
in a case like this are limited to the introduction of ambiguities that are
(a) clearly diagnosed by any decent compiler and (b) easily fixed, so that's
not exactly so evil if you know what you are doing!

Note of course that address arithmetic is something that should in any case
ONLY be used by Ada programmers who know what they are doing (in practice of
course, as one can tell from the somewhat distasteful subject line of this
thread, distasteful because void * is in some ways a crystallization of
what is wrong with C, people often try to use address arithmetic in
inappropriate cases!)

Robert Dewar
Ada Core Technologies


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




  parent reply	other threads:[~1998-10-25  0:00 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-10-23  0:00 simple question - how to emulate void * ? Craig Allen
1998-10-23  0:00 ` Tom Moran
1998-10-23  0:00 ` Dale Stanbrough
1998-10-22  0:00   ` Hans Marqvardsen
1998-10-23  0:00     ` John McCabe
1998-10-23  0:00       ` dennison
1998-10-23  0:00       ` Ed Falis
1998-10-23  0:00         ` dennison
1998-10-24  0:00           ` Joe Wisniewski
1998-10-25  0:00           ` dewar [this message]
1998-10-24  0:00         ` Dale Stanbrough
1998-10-24  0:00           ` Robert A Duff
1998-10-24  0:00           ` Tucker Taft
1998-10-22  0:00   ` Hans Marqvardsen
1998-10-23  0:00   ` David C. Hoos, Sr.
1998-10-23  0:00   ` David C. Hoos, Sr.
1998-10-23  0:00 ` Jeff Carter
1998-10-24  0:00   ` Dale Stanbrough
1998-10-25  0:00     ` dewar
1998-11-05  0:00 ` Craig Allen
1998-11-06  0:00   ` Tom Moran
1998-11-06  0:00   ` Dale Stanbrough
1998-11-06  0:00     ` Matthew Heaney
1998-11-06  0:00       ` dewarr
replies disabled

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