From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8d5151b6052512f7 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-03-09 00:30:10 PST Path: archiver1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!tar-meneldur.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: Overloading procedures with Float and Long_Float types Date: Tue, 09 Mar 2004 09:40:45 +0100 Message-ID: <5lvq40duk2n0eh5nqi30eh7b0dpjkfkq3c@4ax.com> References: <404c7e53.0@entanet> <404c8f63.0@entanet> NNTP-Posting-Host: tar-meneldur.cbb-automation.de (212.79.194.119) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 1078821008 64729051 I 212.79.194.119 ([77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:6175 Date: 2004-03-09T09:40:45+01:00 List-Id: On Mon, 8 Mar 2004 15:18:15 -0000, "Luke Guest" 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