comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Mixing operators and dot notation
Date: Thu, 2 Jun 2016 18:26:12 -0500
Date: 2016-06-02T18:26:12-05:00	[thread overview]
Message-ID: <niqf9v$1nn$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: wccshwvgr8n.fsf@TheWorld.com

"Robert A Duff" <bobduff@TheWorld.com> wrote in message 
news:wccshwvgr8n.fsf@TheWorld.com...
> "Alejandro R. Mosteo" <alejandro@mosteo.com> writes:
>
>> I'm trying to abuse Ada syntax for nefarious purposes and have arrived
>                ^^^^^ Probably an apt description.  ;-)
>
>> at something that looks inconsistent to me, but I fail to see if it is
>                          ^^^^^^^^^^^^
> Yes, the rules are inconsistent.
>
>> expected behavior or a bug. This is a self-contained example which is
>> below.
>
>>    Op (1, 2).Method;  --  Fine
>>
>>    --  (1 & 2).Method;  --  Error: statement expected
>
> That's syntactically illegal; take a look at the BNF.

> But you can say:
>
>   Nest.Object'Class'(1 & 2).Method;
>
> Ada makes a syntactic distinction between 'name' and 'expression',
> which I think is unwise.  ARG has been chipping away at it over
> the years.  Anyway, nowadays, a qualified_expression is a name,
> so if you have an expression you want to use as a name, you can
> just qualify it.

True (for Ada 2012), but it probably defeats the purpose to do that. (If you 
have to know the full expanded names of everything, there's little value to 
prefix notation in the first place.)

You also can write:

    "&" (1, 2).Method

which might defeat the purpose less. (Or not, not knowing the actual 
intent.)

Also to Bob's point, a type conversion always has been a name, so that:

   Nest.Object'Class(1 & 2).Method;

is syntactically legal in Ada 2005 as well, but it not resolve (the operand 
of a type conversion can't use the context in any way, so it depends on what 
& operators are visible as to whether this would work). This was the reason 
that we changed Ada 2012, since it is silly that type conversions would be 
allowed somewhere, but qualified expressions (which just confirm the type) 
would not be.

                            Randy.




  reply	other threads:[~2016-06-02 23:26 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-02 21:38 Mixing operators and dot notation Alejandro R. Mosteo
2016-06-02 21:42 ` Alejandro R. Mosteo
2016-06-02 22:28 ` Robert A Duff
2016-06-02 23:26   ` Randy Brukardt [this message]
2016-06-03 11:09     ` Alejandro R. Mosteo
2016-06-03 12:19       ` Dmitry A. Kazakov
2016-06-03 14:45       ` G.B.
2016-06-03 17:31       ` Shark8
2016-06-03 20:41         ` Alejandro R. Mosteo
2016-06-06  8:14           ` briot.emmanuel
2016-06-06 13:51             ` Alejandro R. Mosteo
2016-06-07 11:24             ` Traits and iterators (was: Mixing operators and dot notation) Alejandro R. Mosteo
2016-06-08  7:31               ` briot.emmanuel
2016-06-08 11:18                 ` Traits and iterators Alejandro R. Mosteo
2016-06-06  8:10       ` Mixing operators and dot notation briot.emmanuel
2016-06-06 13:58         ` Alejandro R. Mosteo
2016-06-02 23:05 ` Jeffrey R. Carter
replies disabled

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