Re: Expression-local variables and 'let'
Daniel Bonniot <[email protected]>
| Newsgroups | gmane.comp.lang.nice.general |
|---|---|
| Message-ID | <[email protected]> |
Isaac Gouy wrote:
>>using(val in = ...) {
>> ...
>>}
>>is more readable than
>>{
>> let in = ...;
>> using (in) {
>> ..
>> }
>>}
>>
>>
>
>Maybe
> using(in = ...){}
>is more readable still,
>
That's already valid, if 'in' is already declared higher. So if you
allow that for undeclared variables, that creates an ambiguity.
>like
> for (i: 1..10){}
>
>
Yes, but that's also problematic. In that case it's feasible, because
for(_ : _) is special syntax. I still don't like it because it's
inconsistent with the rest of the syntax.
using(in = ...) { ... } is pure user code, without any special handling,
so allowing 'in' not to be declared would mean changing the whole
language. That does not seam reasonable.
>>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.
>>
>>
>
>So that in that example there's nothing special about 'Alike' - it's
>just a type parameter?
> <Bar B> B foo(int x, B bar) { ... }
>
>
Yes,
>So 'alike' is a fix for the "within a class" syntax sugar?
>
>
Yes.
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