Re: Expression-local variables and 'let'

Daniel Bonniot <[email protected]>
Newsgroups gmane.comp.lang.nice.general
Message-ID <[email protected]>
Isaac Gouy wrote:

>>What's wrong with alike?
>>    
>>
>
>It's an adjective, in Nice we use it as a pronoun.
>  
>
We use it as a type. Note that Cloneable, Serializable, etc, are also 
adjectives used as types.

>>And it's not like something terrible will happen if you mistake one
>>for the other, either while reading or while writing the code.
>>    
>>
> 
>If that was the case then why have "let" at all? 
>Presumably we think it will help prevent errors.
>  
>
"let" gives more information to the compiler, which can use it during 
the phase of dynamic type inference. Yes, the information that a 
variable is not modified could be computed too, although that could lead 
to surprises if adding an assignment to a 'var' leads to breaking 
seemingly unrelated code.

I'm not completely opposed to using 'var' in all cases. But isn't it 
useful to be able to declare your intent?

>>While, to make a comparison, something "terrible" can happen if you
>>intend to implicitely override a method, but for some reason fail to
>>    
>>
>
>Yes, that would definitely be a mistake. The question is where to catch
>the mistake. It seems that in some circumstances the compiler will be
>able to detect this, and in others it won't. (I may have intended to
>override the method in a subtype, the method is already covered by
>supertype implementations.) 
>  
>
Can you give an example?

>So we still need to write tests.
>  
>
Sure. No compiler will catch all errors anyway. We can still try to make 
it clever ;-)

There is a new unit test runner that will probably be in the next 
release, by the way.

Daniel



-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.