comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: function "and"
Date: Wed, 6 Oct 2004 11:33:55 +0200
Date: 2004-10-06T11:33:55+02:00	[thread overview]
Message-ID: <t9vjbtvydcc6.10k3l4qkp7vrt.dlg@40tude.net> (raw)
In-Reply-To: cjuqtc$pka$02$1@news.t-online.com

On Tue, 5 Oct 2004 20:58:50 +0200, Rick Santa-Cruz wrote:

> if I wanna overload the operator "and" then why I have to use quotes?
> Are there other cases when I have to use quotes?

Everywhere you want to use functional notation instead of operational one.
Compare:

   X, Y : Boolean;
   ...
   if X and Y then -- operator 'and' in infix context
   ...
   if "and" (X, Y) then -- operator 'and' as a function 

Both 'and' and '"and"' refer the same thing, but in different contexts.

When you declare an operator you the only valid notation is functional, so
function "and", function "abs" etc. If 'and' were not a reserved word in
Ada, then one could also declare funny:

function and (X, Y : Boolean) return Boolean
   renames "and"; -- Not legal!

So that:

   (X and Y) = "and" (X, Y) = and (X, Y)

Nevertheless, "and"() and and() cannot be equalized, because otherwise any
unary or binary function declared would automatically become an operator,
and so kill the language grammar.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



      parent reply	other threads:[~2004-10-06  9:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-05 18:58 function "and" Rick Santa-Cruz
2004-10-05 19:20 ` David C. Hoos
2004-10-05 19:22 ` Frank J. Lhota
2004-10-05 19:56 ` Jeffrey Carter
2004-10-05 22:38 ` John Woodruff
2004-10-06  8:18 ` Martin Krischik
2004-10-06  9:33 ` Dmitry A. Kazakov [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox