Re: Expression-local variables and 'let'
Daniel Bonniot <[email protected]>
| Newsgroups | gmane.comp.lang.nice.general |
|---|---|
| Message-ID | <[email protected]> |
>Variable declarations do not feel right in the middle of expresions in general,
>whether "let" or "val" is used.
>
>
Maybe that's only because most language do not support them? If you read
the english sentences in my earliest message today, they do introduce
bindings in the middle of a sentence.
I'm not saying that PL syntax should _look_ like natural language, but I
think that if the structure is similar, it takes less effort to read
(you can get used to any abomination given enough time and effort, of
course). Thinking about it, the move from unstructured to structured
code is only that matches more closely the structure of natural
languages (you don't use 'go to' in natural speach, but you do use 'if').
>>We can go around and around.
>>Seems to me that we're optimizing for the (wild assed guess) 20% of
>>user-defined statements, rather than ordinary assignments. And I'd side
>>with the Ada designers for readability over concision - readability
>>helps me write correct code.
>>
>>
>
>I agree a lot with this sentiment. The proposed syntax is only readable in one
>specialized construct that is hardly used. That is why I still advocate
>"let..in," since it would be useful in the majority of programs and is more general.
>
>
The designers of C++ felt the need to allow variable declarations inside
'while', the designers of C# felt the need to complexify the language to
add a special kind of statement ('using') that includes that same
aspect. Those make sense, and I think it's nice to be able to cover them
with a more general construct: expression-local variables. I also feel
that they will be used in other ways which are yet to be found, allowing
to implement more ideas in user-code (or libraries) rather than as hacks
in the language, which is a goal I cherish. Bryn is already using
block-call syntax in very elegant ways that I did not expect (see his
article about logging), while I was first dubious about this feature.
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