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-Thread: 103376,86d58622defcc2b3,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!news3.google.com!news.glorb.com!newsgate.cistron.nl!news2.euro.net!sn-ams-06!sn-xt-ams-03!sn-post-ams-02!sn-post-sjc-01!supernews.com!corp.supernews.com!not-for-mail From: "Jason C. Wells" Newsgroups: comp.lang.ada Subject: Why is Function Defined Twice? Date: Sun, 14 May 2006 10:55:10 -0700 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <126erl3o7kb1p1a@corp.supernews.com> User-Agent: Thunderbird 1.5 (Windows/20051025) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@supernews.com Xref: g2news2.google.com comp.lang.ada:4250 Date: 2006-05-14T10:55:10-07:00 List-Id: I am trying to do some basic linear algebra as my first non-hello world exercise. I am also trying to work in the concept of library reuse into my exercise. I don't understand why the function ASUM is defined twice in the following example. Which version gets called when I use ASUM? How does Ada determine precedence on which gets called? What is the big concept that I need to associate with this practice so I can go do more studying? These both look like they do the mostly same thing but with different sets of input parameters. Thanks, Jason C. Wells *** This example comes from Ada BLAS at: http://topo.math.u-psud.fr/~sands/Programs/BLAS/html/index.htm function ASUM ( N : Natural; X : Vector_Type; INCX : Natural ) return Float_Type'Base is begin if N > 0 and (N - 1) * INCX >= X'Length then raise Argument_Error; end if; case Precision is when Single => return SCASUM (Fortran_Integer (N), X, Fortran_Integer (INCX)); when Double => return DZASUM (Fortran_Integer (N), X, Fortran_Integer (INCX)); when Unsupported => raise Unsupported_Precision_Error; end case; end ASUM; function ASUM (X : Vector_Type) return Float_Type'Base is begin case Precision is when Single => return SCASUM (X'Length, X, 1); when Double => return DZASUM (X'Length, X, 1); when Unsupported => raise Unsupported_Precision_Error; end case; end ASUM;