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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ad3b8638a6e09884 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news1.google.com!goblin2!goblin1!goblin.stu.neva.ru!newsfeed.straub-nv.de!news-2.dfn.de!news.dfn.de!news.uni-weimar.de!not-for-mail From: stefan-lucks@see-the.signature Newsgroups: comp.lang.ada Subject: Re: Incorrect error? Date: Mon, 18 Jul 2011 14:45:40 +0200 Organization: Bauhaus-Universitaet Weimar Message-ID: References: <4e23f350$0$2573$703f8584@news.kpn.nl> <04f4f840-4ea5-407b-8eb7-1f4016ab4e13@d1g2000yqm.googlegroups.com> Reply-To: stefan-lucks@see-the.signature NNTP-Posting-Host: medsec1.medien.uni-weimar.de Mime-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="8323584-1699836002-1310990753=:1340" X-Trace: tigger.scc.uni-weimar.de 1310991913 22533 141.54.178.228 (18 Jul 2011 12:25:13 GMT) X-Complaints-To: news@tigger.scc.uni-weimar.de NNTP-Posting-Date: Mon, 18 Jul 2011 12:25:13 +0000 (UTC) X-X-Sender: lucks@medsec1.medien.uni-weimar.de In-Reply-To: <04f4f840-4ea5-407b-8eb7-1f4016ab4e13@d1g2000yqm.googlegroups.com> Content-ID: Xref: g2news1.google.com comp.lang.ada:20218 Date: 2011-07-18T14:45:40+02:00 List-Id: This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323584-1699836002-1310990753=:1340 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-1 Content-Transfer-Encoding: 8BIT Content-ID: On Mon, 18 Jul 2011, AdaMagica wrote: > Overloading in this way might be seen as unfortunate. > > > Ada.Numerics.Generic_Real_Arrays actually provides both: > > > > � �function "*" (Left, Right : Real_Vector) return Real'Base; > > � �function "*" (Left, Right : Real_Vector) return Real_Matrix; > > So if you have three vectors, what should A * B * C mean? Even with > parentheses, it's awkward to read. I would always prefer to write such an expression with parenthesis. So look at the expression (A * B) * C, where A, B, and C are vectors. -> A * B is either a matrix M or a number N. -> M * C would be a vector. -> N * C would also be a vector. ===> The result type is a vector. But wait a minute! There are two different results (either "M * C2 or "N * C"), and we don't know which is the correct one. So the compiler should reject this. The issue is that the result type of "A * B" is different from the types of A and B. But, as strange as it seems, this is what generations of Mathematicians and Engineers seem to have found convenient for their work. I am sure, they where able to understand such expressions from context, and to provide the context if necessary. Most authors would probably prefer to write "M * C with the matrix M being A * B" instead of "(A * B) * C" with or without "(", ")". They would thus provide the type information, much like any Ada programmer would (have to) do. > Now image we have a third function > function "*" (Left, Right : Real_Vector) return Real_Vector; > > BTW: What would such a function return for vectors of less or more > than 3 dimensions? It should raise an exception, exactly like function "+" (Left, Right : Real_Vector) return Real_Vector; from the Ada.Numerics.Generic_Real_Array package. I hope the "aspect specifications" from Ada 2012 will allow to specify that the vector dimensions fit. In an ideal world (or maybe in Ada 2017), the compiler would then statically reject the program if the vector dimensions don't fit. > Why is 'Base the return value? You might instantiate the package with > a constrained subtype of Float. 'Base is the unconstrained range. Thus > as long as you stay in the base range, the operators will not > propagate exceptions. Ah, that makes sense! Thank you! -- ------ Stefan Lucks -- Bauhaus-University Weimar -- Germany ------ Stefan dot Lucks at uni minus weimar dot de ------ I love the taste of Cryptanalysis in the morning! ------ --8323584-1699836002-1310990753=:1340--