From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Why is abs an operator, not a function?
Date: Wed, 18 Oct 2006 21:45:24 -0400
Date: 2006-10-18T21:45:24-04:00 [thread overview]
Message-ID: <wcchcy1yt6z.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 1161148425.954662.138180@b28g2000cwb.googlegroups.com
"Jerry" <lanceboyle@qwest.net> 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
next prev parent reply other threads:[~2006-10-19 1:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-18 5:13 Why is abs an operator, not a function? Jerry
2006-10-18 7:30 ` Dmitry A. Kazakov
2006-10-18 7:36 ` Samuel Tardieu
2006-10-19 1:45 ` Robert A Duff [this message]
2006-10-19 4:30 ` Keith Thompson
2006-10-23 2:39 ` Jerry
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox