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-08 06:27:13 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: Mon, 08 Mar 2004 15:37:45 +0100 Message-ID: References: <404c7e53.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 1078756032 64280884 I 212.79.194.119 ([77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:6141 Date: 2004-03-08T15:37:45+01:00 List-Id: On Mon, 8 Mar 2004 14:05:27 -0000, "Luke Guest" wrote: >> >Translate is another st of overloaded functions with the same signature >as >> >Vertex; >> > >> > procedure Translate(X, Y, Z : in GLdouble); >> > procedure Translate(X, Y, Z : in GLfloat); >> > >> >It's just that I've 3 Translate calls and about 40 Vertex calls in my >test >> >program. >> >> This is only possible if you are using literals: >> >> Translate (1.0, 1.0, 1.0); -- This is ambiguous >> >> The compiler does not knwo which kind of Float you mean. >> >> Translate (GLfloat (1.0), 1.0, 1.0); -- This is OK >> >> Now the compiler has a hint. > >It seems that Outlook Express crap, didn't send my last reply *sigh* > >It's a shame that you would have to type GLfloat(1.0) to give the compiler a >hint, is there some float notation that can differentitate bewteen FLoat's >and Long_Float's? GLfloat (1.0) or better GLfloat'(1.0) is exactly that hint. It tells that the numeric literal 1.0 has to be converted to (the first case), or expected to be of (the second case) the designated type. How could it be otherwise? Carefully observe that the type of 1.0 is neither Float nor Long_Float. It is Universal_Real. (see ARM 2.4) However, you can also *imagine* 1.0 as a set of overloaded functions: function "1.0" return Float; function "1.0" return Long_Float; ... -- + many others in presense of other floating/fixed-point types as you see there is no way to decide which one you mean! >Basically, it just seems to be wasting a good opportunity for overloading >here. Surely not. 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. -- Regards, Dmitry Kazakov www.dmitry-kazakov.de