comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Bug in GNAT?
Date: Sat, 9 Nov 2002 15:31:37 GMT
Date: 2002-11-09T15:31:37+00:00	[thread overview]
Message-ID: <wccsmyag3om.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 3dcce11d$0$307$bed64819@news.gradwell.net

porton@ex-code.com (Victor Porton) writes:

> But this compiles with an error:
> 
> function F(A: Integer) return Integer is begin return 1; end;
> Y: Integer renames F(3)+2;
> 
> What is the difference?

Look at the syntax rules.  Renaming requires a "name".  A function_call
is a name, but that thing with "+" in the middle is an "expression",
and not a name.

6.6 says operator notation is equivalent to function call notation,
but that only applies to the semantics -- as this example shows, they
are *not* equivalent syntactically.

    Y: Integer renames "+"(F(3), 2); -- OK
    Y: Integer renames F(3) + 2; -- illegal

I happen to think this is a bug in the language design -- there should
be no syntactic distinction between names and expressions.  And no
distinction between "constant object" and "value".

By the way, the ability to rename function results did not exist in Ada 83.

- Bob



      parent reply	other threads:[~2002-11-09 15:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-09  6:56 Bug in GNAT? Victor Porton
2002-11-09  9:43 ` Michal Nowak
2002-11-09 10:01 ` Victor Porton
2002-11-09 12:26   ` Michal Nowak
2002-11-09 15:26   ` David C. Hoos, Sr.
2002-11-09 15:31   ` Robert A Duff [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