Re: Expression-local variables and 'let'
Daniel Bonniot <[email protected]>
| Newsgroups | gmane.comp.lang.nice.general |
|---|---|
| Message-ID | <[email protected]> |
>>Agreed. Unfortunately, that's also why it does not seem right in the
>>middle of an expression.
>>
>>
>
>We can go around and around.
>
>
Seems so...
>Seems to me that we're optimizing for the (wild assed guess) 20% of
>user-defined statements, rather than ordinary assignments.
>
Good point, expression-local variables are probably much less frequent.
If we can make them nice without making the common case worse, it's all
benefit, though.
>And I'd side
>with the Ada designers for readability over concision - readability
>helps me write correct code.
>
>
I agree the readability is key. I'm not a perl fan... But I think
readability and conciseness are not opposed in principle. In some cases
they are, in some they come together.
I'd say that:
using(val in = ...) {
...
}
is more readable than
{
let in = ...;
using (in) {
..
}
}
since the second form, because of the extra braces and line, obscures
the purpose of the code.
>Cloneable and Serializable are not of our making, they are gifts from
>Java used as nouns. And they make some sort of sense, implementors of
>Cloneable are cloneable.
>
>IIRC 'alike' corresponds to the type in the same way that 'this'
>corresponds to the instance of that type - 'alike' is 'selftype' or
>'thistype'.
>
>
Right. The term 'alike' is also commonly used for this concept, I did
not invent it.
>I understand Brian's discomfort with 'alike'.
>OTOH we say that these are multimethods and there is no privileged
>method receiver; OTOH we don't have a way to express 'alike' when the
>method is outside a class.
>
>
You can, and for any parameter, using a constrained type parameter:
class Bar { ...}
<Bar Alike> Alike foo(int x, Alike bar) { ... }
The thing is that for methods declared inside a class, there is no way
to constrain the type of this, so 'alike' was needed.
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