comp.lang.ada
 help / color / mirror / Atom feed
From: Robert Dewar <robert_dewar@my-deja.com>
Subject: Re: About conversions
Date: 2000/11/20
Date: 2000-11-20T00:00:00+00:00	[thread overview]
Message-ID: <8vbfds$dih$1@nnrp1.deja.com> (raw)
In-Reply-To: RaaS5.5488$6W1.468063@news.flash.net

In article <RaaS5.5488$6W1.468063@news.flash.net>,
  "Ken Garlington" <Ken.Garlington@computer.org> wrote:


<<much general and probably irrelevant material on type
conversions removed>>

> In your example, you have a
> procedure P that expects values of type Integer, you convert
> your Typ value
> to an Integer value before calling P, so everything is
> consistent.

No, that's quite wrong. Ken misread the example.
This is indeed the "weird" case where
a type conversion is used on an OUT parameter. Even someone who
understands all the stuff about type conversions in general
can be puzzled at this peculiar use.

The deal here is that the conversion happens AFTER the call
in the OPPOSITE direction from what it looks like. So if the
call says

  p (10,20,integer(c));

the actual effect is that the function computes something of
type Integer and puts it in the output parameter. This value is
then converted FROM integer TO type "typ" and stored in C.

How's that for strange? The conversion is exactly "backwards".
In the case of an IN OUT parameter, you get two conversions, one
the way that it looks (and to which Ken was referring
incorrectly above, not having noticed the OUT keyword), and one
the peculiar opposite direction.

Why is this feature in the language?

It's really there to provide an easy explanation for what
happens in the case of derived types. I think it's actually
misguided, because although it makes the explanation of derived
types easier, it introduces a bogus misleading feature into the
language that is of very little practical use and which causes a
lot of confusion, even among people who know Ada well!

Robert Dewar


Sent via Deja.com http://www.deja.com/
Before you buy.




  reply	other threads:[~2000-11-20  0:00 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-20  0:00 About conversions Sandro Binetti
2000-11-20  0:00 ` Ken Garlington
2000-11-20  0:00   ` Robert Dewar [this message]
2000-11-20  0:00     ` Stephen Leake
2000-11-21  0:00       ` Robert Dewar
2000-11-21  0:00         ` Warren W. Gay VE3WWG
2000-11-21  0:00           ` Robert Dewar
2000-11-21  0:00             ` Ted Dennison
2000-11-22  3:27               ` Warren W. Gay VE3WWG
2000-11-22  4:54               ` Robert Dewar
2000-11-22  0:00                 ` Wes Groleau
2000-11-22  0:00                 ` Ted Dennison
2000-11-22  0:00         ` Tristan Gingold
2000-11-24  0:00         ` Jean-Pierre Rosen
2000-11-24  0:00       ` Jean-Pierre Rosen
2000-11-21  2:57     ` DuckE
2000-11-21  0:00       ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
2000-11-23  6:21 Christoph Grein
2000-11-23  0:00 ` Wilhelm Spickermann
2000-11-23  0:00   ` Florian Weimer
2000-11-23  0:00     ` Wilhelm Spickermann
2000-11-28  2:20   ` Robert Dewar
2000-11-24  0:00 Christoph Grein
2000-11-28  1:33 ` Robert Dewar
replies disabled

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