comp.lang.ada
 help / color / mirror / Atom feed
From: Dmitry A. Kazakov <mailbox@dmitry-kazakov.de>
Subject: Re: user-defined type conversion
Date: Tue, 21 May 2002 11:18:07 +0200
Date: 2002-05-21T11:18:07+02:00	[thread overview]
Message-ID: <cf3keug26uab9b4ovqg6olco4b8a873fco@4ax.com> (raw)
In-Reply-To: 3CE8154B.E28B7880@acm.org

On Sun, 19 May 2002 21:12:56 GMT, Jeffrey Carter <jrcarter@acm.org>
wrote:

>Russ wrote:
>> 
>> "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com> wrote in message news:<mailman.1021805103.320.comp.lang.ada@ada.eu.org>...
>> > No, because a type conversion has the same syntax as a function, so
>> > there's no way to "read the programmer's mind," as to what he intended.
>> 
>> Type conversion IS a function!
>
>Are you sure? Given
>
>type Real is new Float;
>
>F : Float;
>R : Real;
>
>a statement such as
>
>R := Real (F);
>
>probably has no code generated for the type conversion. No function
>call, no inline expansion, nothing.

So what? A function that does nothing is still a function. More
interesting is the following:

   procedure Increment (X : in out Float);
   I : Integer := 1;
begin
   Increment  (Float (I));

Here Float is a pair of functions: To_Float and From_Float and
Increment  (Float (..)) is a composition:

To_Float o Increment o From_Float

---
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



  reply	other threads:[~2002-05-21  9:18 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-19  7:44 user-defined type conversion Russ
2002-05-19  8:54 ` martin.m.dowie
2002-05-19 10:44 ` David C. Hoos, Sr.
2002-05-19 18:29   ` Russ
2002-05-19 20:58     ` David C. Hoos, Sr.
2002-05-19 21:12     ` Jeffrey Carter
2002-05-21  9:18       ` Dmitry A. Kazakov [this message]
2002-05-19 19:01 ` sk
2002-05-20  3:33   ` Russ
2002-05-20 19:27     ` Randy Brukardt
2002-05-20 19:45       ` David C. Hoos
2002-05-19 21:17 ` Jeffrey Carter
2002-05-20  3:25   ` Russ
2002-05-20  6:21     ` Jeffrey Carter
2002-05-21  9:30       ` Dmitry A. Kazakov
     [not found]     ` <mailman.1021892102.6644.comp.lang.ada@ada.eu.org>
2002-05-20 19:26       ` Russ
2002-05-21  9:35         ` Dmitry A. Kazakov
2002-05-22  4:32         ` Russ
replies disabled

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