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,1540032852ee6d61 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!s48g2000cws.googlegroups.com!not-for-mail From: "Jerry" Newsgroups: comp.lang.ada Subject: Re: Why does this work? (overloads) Date: 6 Feb 2007 23:07:36 -0800 Organization: http://groups.google.com Message-ID: <1170832056.546904.122390@s48g2000cws.googlegroups.com> References: <1170823163.681564.186260@s48g2000cws.googlegroups.com> NNTP-Posting-Host: 67.40.87.12 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1170832073 30056 127.0.0.1 (7 Feb 2007 07:07:53 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 7 Feb 2007 07:07:53 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US) AppleWebKit/420+ (KHTML, like Gecko, Safari/420) OmniWeb/v607.16,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: s48g2000cws.googlegroups.com; posting-host=67.40.87.12; posting-account=Ax24hA0AAABV39UFqUVhb0kauOuAbI3T Xref: g2news2.google.com comp.lang.ada:9051 Date: 2007-02-06T23:07:36-08:00 List-Id: On Feb 6, 11:45 pm, "Grein, Christoph (Fa. ESG)" wrote: > > H := 1.0 + f * x; -- Adds scalar, 1.0, to a vector using my overload > > above. > > a := 1.0 + f * x; -- Adds scalar, 1.0, to another scalar, an inner > > product. > > This feature is called overloading. > > For a problematic example, consider X := A*B*C; where all four are > vectors. > > Is it (A*B) inner product * C resulting in vector or > (A*B) vector * C resulting in vector. > The compiler can't tell and will reject the code. Hmm.... You're right, of course. Plus, (A*B) matrix * C where A*B is taken as an outer product. The compiler did reject it, so at least (with this example) I can't generate incorrect results, but I have to tweak my code. I wish that I could define new operators. I suppose there's always the ugly: type Math_Operator is ('+', '-', '*', '/'); function el(Left : Real_Vector; op : Math_Operator; Right : Real_Vector) return Real_Vector is Jerry