comp.lang.ada
 help / color / mirror / Atom feed
From: dennison@telepath.com (Ted Dennison)
Subject: Re: Is this a GNAT bug???
Date: 1 May 2002 10:08:35 -0700
Date: 2002-05-01T17:08:36+00:00	[thread overview]
Message-ID: <4519e058.0205010908.7ebc64fd@posting.google.com> (raw)
In-Reply-To: db500a4f.0204301731.391cd20a@posting.google.com

robert_s_quinn@yahoo.com (Robert Quinn) wrote in message news:<db500a4f.0204301731.391cd20a@posting.google.com>...
> tmoran@acm.org wrote in message news:<9gBz8.4053$451.2378814669@newssvr21.news.prodigy.com>...
> >   This is not good Ada.  [snip] There is no reason to
> > assume an unchecked conversion from System.Address to an access
> > type will work as you hope.

...unless your vendor docs say it will. It will render your code
non-portable, but sometimes you might not care. Personally, I'd go for
the portable way though.

> Ahh, thanks for the note.  I used the Unchecked_Conversion out of
> ignorance and habit, since the system I actually work on uses it a
> lot.  Addresses are passed between tasks and then converted to an
> appropriate access type.  Or sometimes data is read off a socket, an
> address passed to a task, then converted to an appropriate access
> type.  So I've seen this method used for both intertask communications
> and for client-server communications.

That was probably old Ada83 code. Folks did that stuff a lot in Ada83,
as there was no other good way to get a pointer to a stack object.

Today, we would use 'Access (or 'Unchecked_Access), and keep
everything nice and type-safe.

Passing addresess or accesses between tasks seems kinda dangerous. I
don't know what their code did, so perhaps they carefully analyzed
things, discovered that for some arcane reason this was the only way
to pass their data, and made sure to access the contents safely.
However, if I were a betting man, I'd be willing to wadger quite a bit
that they did this because they stupidly thought Ada didn't pass
parameters by reference (like older C doesn't), and that they have a
race-condition in there. You certianly shouldn't clone such code
yourself unless you really know what you are doing.


-- 
T.E.D. 
Home     -  mailto:dennison@telepath.com (Yahoo: Ted_Dennison)
Homepage -  http://www.telepath.com/dennison/Ted/TED.html



  reply	other threads:[~2002-05-01 17:08 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-26 16:36 Is this a GNAT bug??? Robert Quinn
2002-04-26 17:48 ` Mark Johnson
2002-04-26 22:20   ` Robert Dewar
2002-04-29 15:45   ` Robert Quinn
2002-04-30  2:44     ` Robert Dewar
2002-04-30 14:15       ` Larry Kilgallen
2002-04-30 16:41       ` Robert Quinn
2002-04-30 18:20         ` tmoran
2002-05-01  1:31           ` Robert Quinn
2002-05-01 17:08             ` Ted Dennison [this message]
2002-05-02  1:55               ` Larry Kilgallen
2002-05-02 14:04                 ` Mark Johnson
2002-05-02 15:25                   ` Larry Kilgallen
2002-04-30 21:55         ` Mark Johnson
2002-05-01 22:59           ` Nick Roberts
2002-05-02 13:56             ` Mark Johnson
2002-05-02 20:19               ` Nick Roberts
2002-05-02 21:55                 ` Mark Johnson
  -- strict thread matches above, loose matches on Subject: below --
2003-09-20 22:50 Is this a gnat bug? Waldek Hebisch
2003-09-20 23:09 ` Ludovic Brenta
2003-09-21  2:37 ` Waldek Hebisch
replies disabled

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