comp.lang.ada
 help / color / mirror / Atom feed
From: Dmitry A. Kazakov <mailbox@dmitry-kazakov.de>
Subject: Re: Overloading procedures with Float and Long_Float types
Date: Tue, 09 Mar 2004 09:40:45 +0100
Date: 2004-03-09T09:40:45+01:00	[thread overview]
Message-ID: <5lvq40duk2n0eh5nqi30eh7b0dpjkfkq3c@4ax.com> (raw)
In-Reply-To: 404c8f63.0@entanet

On Mon, 8 Mar 2004 15:18:15 -0000, "Luke Guest" <lguest@bubball.com>
wrote:

>> Generally, oveloading is not a very brilliant idea in the case like
>> yours. Overloading is a way to make different things look similar.
>> (polymorphic as it called in OO) And what is a difference between
>> Float and Long_Float? The length of mantissa? This is a pure
>> implementation detal, which has to be hidden. IMO the actual problem
>> here is bad design. If you are witting an OpenGL application you have
>> to choose which precision is suitable for this concrete application.
>> If you are designing bindings to OpenGL, then it is better to place
>> float and double things in two different [paths of] packages. And
>> finally, calling subroutines with "magic" numeric literals is the most
>> obscure way of programming.
>
>Hmmm, this will also mean, that glVertex[234][is] wil cause problems here
>(integer vertices). I also don't think it makes sense design wise to move
>them into separate packages for int, short, float, double, as some apps
>would like to mix them.

No problem, they can always "use" the packages. In case of ambiguity
full names would resolve the problem:

GL.Long.Translate (...) vs. GL.Short.Translate (...)

>Maybe a good compromise here would be to either:
>
>1) Not use overloading, and postfix the procedure call with the type, a la
>OpenGL [FD], or
>2) Move into separate packages and overload on number of parameters, a la
>OpenGL [234].

How frequently are you going to use only "magic numbers" parameters?
If you are creating thick bindings, then for frequently used calls on
vectors like (1, 0, 0), you can give some meaningful names. Further,
thick bindings should have vector types, rather than co-ordinate
parameters:

package GL.Long is
   type Real is ...;
   type Vector is record
      X, Y, Z : Real;
   end record;
   procedure Translate (Translation_Vector : Vector);

package GL.Short is
   type Real is ...;
   type Vector is record
      X, Y, Z : Real;
   end record;
   procedure Translate (Translation_Vector : Vector);

Of course these could be instantiations of some generic package with
some floating point type as a parameter.

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



  parent reply	other threads:[~2004-03-09  8:40 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-08  0:17 Overloading procedures with Float and Long_Float types Luke A. Guest
2004-03-08  3:49 ` James Rogers
2004-03-08  8:16   ` Luke A. Guest
2004-03-08  8:20     ` Preben Randhol
2004-03-08  9:06       ` Luke A. Guest
2004-03-08 10:10         ` Dmitry A. Kazakov
2004-03-08 14:05           ` Luke Guest
2004-03-08 14:07             ` Preben Randhol
2004-03-08 15:10               ` Luke Guest
2004-03-08 16:20                 ` Preben Randhol
2004-03-08 16:28                   ` Luke Guest
2004-03-08 17:58                     ` Preben Randhol
2004-03-09  8:55                       ` Dmitry A. Kazakov
2004-03-08 16:50                   ` Hyman Rosen
2004-03-08 16:55                     ` Luke Guest
2004-03-08 17:32                       ` Hyman Rosen
2004-03-08 14:37             ` Dmitry A. Kazakov
2004-03-08 15:18               ` Luke Guest
2004-03-08 19:52                 ` Gautier Write-only
2004-03-08 20:34                   ` Luke A. Guest
2004-03-09  8:40                 ` Dmitry A. Kazakov [this message]
2004-03-08 12:46 ` David C. Hoos
2004-03-08 14:03   ` Luke Guest
2004-03-08 14:54     ` Georg Bauhaus
2004-03-08 15:19       ` Luke Guest
2004-03-08 16:04     ` David C. Hoos
2004-03-08 16:17       ` Luke Guest
2004-03-09  9:24         ` Dmitry A. Kazakov
2004-03-08 19:58       ` Gautier Write-only
     [not found]     ` <1faf01c40527$0a364a10$b101a8c0@sy.com>
2004-03-08 16:21       ` Preben Randhol
replies disabled

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