comp.lang.ada
 help / color / mirror / Atom feed
* Relational Operators
@ 2001-10-26 12:41 Gordon Cooke
  2001-10-26 13:57 ` Preben Randhol
  2001-10-26 14:10 ` Ted Dennison
  0 siblings, 2 replies; 9+ messages in thread
From: Gordon Cooke @ 2001-10-26 12:41 UTC (permalink / raw)


Is this code legal?

procedure Test is
   B : Boolean;
begin
   B := True = True = True;
end Test;


I thought this would be parsed as:

procedure Test is
   B : Boolean;
begin
   B := (True = True) = True;
end Test;


but GNAT 3.13p states:

     4.    B := True = True = True;
                            |
        >>> unexpected relational operator

 5 lines: 1 error


Gordon



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Relational Operators
  2001-10-26 12:41 Relational Operators Gordon Cooke
@ 2001-10-26 13:57 ` Preben Randhol
  2001-10-26 14:42   ` Ted Dennison
  2001-10-26 14:10 ` Ted Dennison
  1 sibling, 1 reply; 9+ messages in thread
From: Preben Randhol @ 2001-10-26 13:57 UTC (permalink / raw)


On Fri, 26 Oct 2001 13:41:05 +0100, Gordon Cooke wrote:
> Is this code legal?
> 
> procedure Test is
>    B : Boolean;
> begin
>    B := True = True = True;
> end Test;

Consider:

B := True = 5 = 5;

If you write it as:

B := (True = 5) = 5;

you will get at compile time:

tests.adb:6:16: invalid operand types for operator "="
tests.adb:6:16: left operand has type universal integer
tests.adb:6:16: right operand has type "Standard.Boolean"

but change it to:

B := True = (5 = 5);

and it will be legal.

Preben



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Relational Operators
  2001-10-26 12:41 Relational Operators Gordon Cooke
  2001-10-26 13:57 ` Preben Randhol
@ 2001-10-26 14:10 ` Ted Dennison
  2001-10-29  8:44   ` tgingold
  1 sibling, 1 reply; 9+ messages in thread
From: Ted Dennison @ 2001-10-26 14:10 UTC (permalink / raw)


In article <3BD959E1.6C0AD647@hotmail.com>, Gordon Cooke says...
>
>Is this code legal?
>
>procedure Test is
>   B : Boolean;
>begin
>   B := True = True = True;
>end Test;

Yes. It looks like you found a compiler bug in Gnat. Good job. :-)

---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html

No trees were killed in the sending of this message. 
However a large number of electrons were terribly inconvenienced.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Relational Operators
  2001-10-26 13:57 ` Preben Randhol
@ 2001-10-26 14:42   ` Ted Dennison
  0 siblings, 0 replies; 9+ messages in thread
From: Ted Dennison @ 2001-10-26 14:42 UTC (permalink / raw)


In article <slrn9tj29n.4ne.randhol+abuse@kiuk0156.chembio.ntnu.no>, Preben
Randhol says...
>
>On Fri, 26 Oct 2001 13:41:05 +0100, Gordon Cooke wrote:
>> Is this code legal?
>> 
>> procedure Test is
>>    B : Boolean;
>> begin
>>    B := True = True = True;
>> end Test;
>
>Consider:
>
>B := True = 5 = 5;

Perhaps. But in the first case all operands and all possible permutations of
results are the same type (boolean). 

---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html

No trees were killed in the sending of this message. 
However a large number of electrons were terribly inconvenienced.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Relational Operators
  2001-10-26 14:10 ` Ted Dennison
@ 2001-10-29  8:44   ` tgingold
  2001-10-29 10:47     ` Martin Dowie
  0 siblings, 1 reply; 9+ messages in thread
From: tgingold @ 2001-10-29  8:44 UTC (permalink / raw)


In article <69eC7.1430$xS6.1903@www.newsranger.com>, Ted Dennison wrote:
> In article <3BD959E1.6C0AD647@hotmail.com>, Gordon Cooke says...
>>
>>Is this code legal?
>>
>>procedure Test is
>>   B : Boolean;
>>begin
>>   B := True = True = True;
>>end Test;
> 
> Yes. It looks like you found a compiler bug in Gnat. Good job. :-)
No, this code is not legal:
according to LRM 4.4:
relation ::= 
     simple_expression [relational_operator simple_expression]
   | simple_expression [not] in range
   | simple_expression [not] in subtype_mark

And LRM 4.5 says:
relational_operator ::=   =   | /=  | <   | <= | > | >=

Therefore, A = B = C is not legal.

Tristan.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Relational Operators
  2001-10-29  8:44   ` tgingold
@ 2001-10-29 10:47     ` Martin Dowie
  2001-10-29 13:41       ` Pascal Obry
  2001-10-29 19:31       ` David Starner
  0 siblings, 2 replies; 9+ messages in thread
From: Martin Dowie @ 2001-10-29 10:47 UTC (permalink / raw)


<tgingold@pc204.ipricot.fr> wrote in message
news:9rj4tf$piq$1@st520.dotcom.fr...
> In article <69eC7.1430$xS6.1903@www.newsranger.com>, Ted Dennison wrote:
> > In article <3BD959E1.6C0AD647@hotmail.com>, Gordon Cooke says...
> >>
> >>Is this code legal?
> >>
> >>procedure Test is
> >>   B : Boolean;
> >>begin
> >>   B := True = True = True;
> >>end Test;
> >
> > Yes. It looks like you found a compiler bug in Gnat. Good job. :-)
> No, this code is not legal:
> according to LRM 4.4:
> relation ::=
>      simple_expression [relational_operator simple_expression]
>    | simple_expression [not] in range
>    | simple_expression [not] in subtype_mark
>
> And LRM 4.5 says:
> relational_operator ::=   =   | /=  | <   | <= | > | >=


Does this tie in with Robert Dewar's point about LRM references in
compiler messages?

e.g.
GNAT
test.adb:4:21: unexpected relational operator

ObjectAda
test.adb: Error: line 4 col 21 LRM:4.4(3), Operand of = cannot be
another relational operation, Inserting parentheses

I know which I found more useful, but perhaps this is just "My Opinion"







^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Relational Operators
  2001-10-29 10:47     ` Martin Dowie
@ 2001-10-29 13:41       ` Pascal Obry
  2001-10-29 19:31       ` David Starner
  1 sibling, 0 replies; 9+ messages in thread
From: Pascal Obry @ 2001-10-29 13:41 UTC (permalink / raw)



"Martin Dowie" <martin.dowie@nospam.baesystems.com> writes:

> GNAT
> test.adb:4:21: unexpected relational operator
> 
> ObjectAda
> test.adb: Error: line 4 col 21 LRM:4.4(3), Operand of = cannot be
> another relational operation, Inserting parentheses
> 
> I know which I found more useful, but perhaps this is just "My Opinion"

Indeed. GNAT could do better here. Please be sure to submit a report to ACT.

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|         http://perso.wanadoo.fr/pascal.obry
--|
--| "The best way to travel is by means of imagination"



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Relational Operators
  2001-10-29 10:47     ` Martin Dowie
  2001-10-29 13:41       ` Pascal Obry
@ 2001-10-29 19:31       ` David Starner
  2001-10-30  9:02         ` Martin Dowie
  1 sibling, 1 reply; 9+ messages in thread
From: David Starner @ 2001-10-29 19:31 UTC (permalink / raw)
  To: Robert Dewar

On Mon, 29 Oct 2001, in comp.lang.ada, Martin Dowie wrote:
> Does this tie in with Robert Dewar's point about LRM references in
> compiler messages?
> 
> e.g.
> GNAT
> test.adb:4:21: unexpected relational operator
> 
> ObjectAda
> test.adb: Error: line 4 col 21 LRM:4.4(3), Operand of = cannot be
> another relational operation, Inserting parentheses
> 
> I know which I found more useful, but perhaps this is just "My Opinion"

But I don't see wht the LRM reference adds. "Operand of = cannot be
another relational operation" alone is better than the GNAT message,
with or without the LRM reference (and I'm really not much interested in
the functionings of the compiler error-correcting routines.)

-- 
David Starner - dstarner98@aasaa.ofe.org
Pointless website: http://dvdeug.dhis.org
"I saw a daemon stare into my face, and an angel touch my breast; each 
one softly calls my name . . . the daemon scares me less."
- "Disciple", Stuart Davis



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Relational Operators
  2001-10-29 19:31       ` David Starner
@ 2001-10-30  9:02         ` Martin Dowie
  0 siblings, 0 replies; 9+ messages in thread
From: Martin Dowie @ 2001-10-30  9:02 UTC (permalink / raw)


"David Starner" <dvdeug@x8b4e53cd.dhcp.okstate.edu> wrote in message
news:9rkaqs$8201@news.cis.okstate.edu...
> On Mon, 29 Oct 2001, in comp.lang.ada, Martin Dowie wrote:
> But I don't see wht the LRM reference adds. "Operand of = cannot be
> another relational operation" alone is better than the GNAT message,
> with or without the LRM reference (and I'm really not much interested in
> the functionings of the compiler error-correcting routines.)

Well, in this instance, it would point out to me that I've tried something
I didn't understand, so the LRM pointer at least tells me which area of the
language to bone up on. Even if I can't fathom out what the LRM is saying,
I would then know to go and pull out my Barnes and Cohen books and what
chapters to read!

Just a little slow I guess... :-)





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2001-10-30  9:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-26 12:41 Relational Operators Gordon Cooke
2001-10-26 13:57 ` Preben Randhol
2001-10-26 14:42   ` Ted Dennison
2001-10-26 14:10 ` Ted Dennison
2001-10-29  8:44   ` tgingold
2001-10-29 10:47     ` Martin Dowie
2001-10-29 13:41       ` Pascal Obry
2001-10-29 19:31       ` David Starner
2001-10-30  9:02         ` Martin Dowie

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