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,ab436e97ff76821f X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.196.232 with SMTP id ip8mr24645980pbc.6.1341922830629; Tue, 10 Jul 2012 05:20:30 -0700 (PDT) Path: l9ni11278pbj.0!nntp.google.com!news1.google.com!goblin2!goblin.stu.neva.ru!aioe.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Brian Drummond Newsgroups: comp.lang.ada Subject: Re: Does Ada need elemental functions to make it suitable for scientific work? Date: Tue, 10 Jul 2012 12:20:29 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Injection-Date: Tue, 10 Jul 2012 12:20:29 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="0e44dd4a3c4e0a6e83a86f947fb780ae"; logging-data="24135"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Bv+1HbLJlgeV16eOHAJ4V9OGaskbTzoA=" User-Agent: Pan/0.135 (Tomorrow I'll Wake Up and Scald Myself with Tea; GIT 30dc37b master) Cancel-Lock: sha1:w4BqKuCv9wdzwg7GGfUwBsTPnGg= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Date: 2012-07-10T12:20:29+00:00 List-Id: On Mon, 09 Jul 2012 18:27:54 -0500, Nasser M. Abbasi wrote: On Mon, 09 Jul 2012 18:27:54 -0500, Nasser M. Abbasi wrote: > The most important feature which I found missing is that Ada functions > do not automatically work on arrays and matrices. Everyone moving from a domain-specific language to a general one will have a "most important missing feature". > In Fortran, I can just write V**2, where V is a vector. In Ada, > I can't do that. Since ** is not defined on this array type and this > number type. > > ... I really do not want to write packages and > define operators each time and for each type I make to have it work as > elemental function each time. > > This is something that should be build into the language. No, it is something that can be added to the language where necessary, with the minimum of wasted effort. For example, write ONCE, a generic ** function, which you can instantiate with any (numeric!) array type. Now a package of such generic functions, extending Numerics.Generic_Real_Arrays, might be a useful addition to Ada. O course it would have to be clear from the package documentation which of the possible meanings of "**" was implemented. You might want separate packages implementing element_wise operators or array operators. Or you may want different ad-hoc operator symbols, like "^" or ".^" in your Octave examples, to distinguish the different meanings. (But in your examples, even the domain-specific languages can't agree to use the same symbols!) This would be one use case for my recent proposal to allow user- defined operator symbols in a future Ada. Given a few restrictions, (e.g. on operator precedence) it looked like a relatively harmless addition to Ada, and fairly general in application (not specific to one domain). - Brian