Re: Eiffel syntax and the ';'

alan lamer <[email protected]> Fri, 19 Aug 2005 13:26:50 +0200 (CEST)
Newsgroups gmane.comp.lang.eiffel.smalleiffel
Message-ID <[email protected]>
> 
> Here, the compiler is confronted by two possible
> interpretations:
>      x.f;
>      (x + x).f;
> or  x.f(x + x).f;
> 
> While you might think that the compiler ought to be
> smart enough to know 
> the first is what is intended, since the second line
> of the first is 
> valid, the compiler must never assume intention. You
> might very well 
> have intended the second and mis-typed the name of
> the routine call with 
> argument (easy to do with cryptic one-letter names).

Well, beyond the fact the first interpretation was of
course intended, the second interpretation is always
false since Eiffel doesn't allow function polymophism.
So as long as 
   class X
      [...]
   feature
       f is do .... end
       f (x: Y) is do .... end
      [...]
   end
is forbidden, there can't be any ambiguity.


> Compilers will 
> always err on the side of caution and throw an error
> telling you to be 
> explicit. This protects you from your own mistakes.
> 

Again, as long as overloading is not allowed in Eiffel
for function prototypes (such as in C++), the code i
wrote was definitively not a mistake since there is no
ambiguity.

> This situation exists for your example because you
> are using a source 
> shortcut to create an anonymous object "(x + x)" on
> which you call a 
> routine. If you choose to use such shortcuts you
> must be ready to handle 
> the possible resulting uncommon situations, like an
> explicit statement 
> terminator.

I don't consider this as a shortcut but as a
construction allowed by the language.

And according to the response of Berend de Boer, i
will consider this as a compiler bug.

thx.



	

	
		
___________________________________________________________________________ 
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger 
Téléchargez cette version sur http://fr.messenger.yahoo.com