Eiffel "Gotcha" #7 - redundant parentheses 
Author Message
 Eiffel "Gotcha" #7 - redundant parentheses

In Eiffel, as in most computer languages, it does no harm to include
parentheses that are redundant (do not affect the order of computation).

Or does it? How can you break a valid, working program by adding a
single pair of parentheses that do not affect the order of computation.

Answer tomorrow.
--
--
-- Roger Browne, 6 Bambers Walk, Wesham, PR4 3DG, UK | Ph 01772-687525
-- Everything Eiffel: http://www.*-*-*.com/ | +44-1772-687525



Fri, 05 Nov 1999 03:00:00 GMT  
 Eiffel "Gotcha" #7 - redundant parentheses

|> Roger Browne:
|>
|> > Or does it? How can you break a valid, working program by adding a
|> > single pair of parentheses that do not affect the order of computation.
|>
|>     -- works
|>     a.something
|>     b.something.else
Don't works, because of the keyword "else"  ;-)
--
------------------------------------------------------------
Dominique COLNET -- Talk Eiffel with SmallEiffel Talk Eiffel
C.R.I.N. (Centre de Recherche en Informatique de Nancy)
POST: CRIN,BP 239,54506 Vandoeuvre les Nancy Cedex,FRANCE



Sat, 06 Nov 1999 03:00:00 GMT  
 Eiffel "Gotcha" #7 - redundant parentheses

Quote:
> > How can you break a valid, working program by adding a
> > single pair of parentheses that do not affect the order of computation.

>     -- works
>     a.something
>     b.something.else

>     -- does not compile
>     a.something
>     (b.something).else

>     -- works again
>     a.something;
>     (b.something).else

Correct, and succinctly put! The second example fails because the parser
ignores line endings, and treats "something(b.something)" as a function call.
As Franck suggests, a semicolon makes it clear to the parser that we have
reached the end of the first instruction.

[Aside: in Franck's example, note that the 'something' applied to 'a' is
a procedure, and the 'something' applied to 'b' is a function. Of course this
is no problem if 'a' and 'b' are of unrelated types.]

Regards,
Roger
--
--
-- Roger Browne, 6 Bambers Walk, Wesham, PR4 3DG, UK | Ph 01772-687525
-- Everything Eiffel: http://www.eiffel.demon.co.uk/ | +44-1772-687525



Sat, 06 Nov 1999 03:00:00 GMT  
 Eiffel "Gotcha" #7 - redundant parentheses

Roger Browne:

Quote:
> Or does it? How can you break a valid, working program by adding a
> single pair of parentheses that do not affect the order of computation.

    -- works
    a.something
    b.something.else

    -- does not compile
    a.something
    (b.something).else

    -- works again
    a.something;
    (b.something).else



Sat, 06 Nov 1999 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Eiffel "Gotcha" #10 - discounts

2. Eiffel "Gotcha" #12 - onceness and invariants

3. Eiffel "Gotcha" #10 - cleaning up

4. Eiffel "Gotcha" #9 - postconditions

5. string.join(["Tk 4.2p2", "Python 1.4", "Win32", "free"], "for")

6. BEGIN{want[]={"s1o", "s2o", "s2q", "s3q"}

7. Building a "record" in Eiffel

8. Obvious Fake (was "Record in Eiffel")

9. Who is working on "Visual Eiffel"?

10. "Eiffel: The Language" available in French

11. "Eiffel in Education" ***UPDATE***

12. UK&I EIG meeting: "Eiffel in Education", Bristol, 16th March

 

 
Powered by phpBB® Forum Software