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,8f0924b09d1aa9d2 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newscon02.news.prodigy.net!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Why is abs an operator, not a function? Date: Wed, 18 Oct 2006 21:45:24 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1161148425.954662.138180@b28g2000cwb.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1161222324 11270 192.74.137.71 (19 Oct 2006 01:45:24 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Thu, 19 Oct 2006 01:45:24 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:JWS/u4UYNh/WinBW7reBDmGCBBA= Xref: g2news2.google.com comp.lang.ada:7035 Date: 2006-10-18T21:45:24-04:00 List-Id: "Jerry" writes: > Why is abs an operator and not a function? Just wondering. An operator _is_ a function. So the question really is, why is the name of the abs function an operator symbol (a reserved word) rather than an identifier? In early (pre-1983) versions of Ada, Abs was not an operator -- just a normal function with identifier Abs as its name. I think it was changed to make implementations easier -- implementations usually special-case the overloading resolution for operator symbols, since they are so heavily overloaded. Maybe the fact that all predefined functions are operators simplifies that. Not a big deal, but it does have a certain uniformity -- e.g. "not" is an operator symbol, too, and works the same way as "abs". > Is there no way to write a function abs() that, say, computes the > absolute value of each of the components of a float array? As others have pointed out, you can write a such an "abs" function. If you want to call it like this: abs(X) that's fine. - Bob