Mozilla Rust 0.1

Chad J chadjoan at __spam.is.bad__gmail.com
Sat Jan 28 22:15:50 PST 2012


On 01/27/2012 07:55 PM, bearophile wrote:
> I've just read this tutorial about Rust and I've extracted some interesting bits:
> http://doc.rust-lang.org/doc/tutorial.html
>
> My comments are in inside [...].
>
> ...
> --------------------
>
>  From 5.3:
>
> To run such an iteration, you could do this:
>
> for_rev([1, 2, 3], {|n| log(error, n); });
>
> Making use of the shorthand where a final closure argument can be moved outside of the parentheses permits the following, which looks quite like a normal loop:
>
> for_rev([1, 2, 3]) {|n|
>      log(error, n);
> }
>
> [A similar simple syntax sugar was proposed for D too.]
>

Yes please.

It sounds similar to stuff I've mentioned about mixins/templates before:
http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=95579

Also this, and it references the former:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=105781

Those links were mostly about mixins, but it seemed very related to this 
idea of turning a trailing predicate into it's own statement block.  And 
of course, mixins could be super handy things, except that I'm probably 
going to avoid using them unless I really need to simply because they 
are just awful to look at.  That may sound silly, but to me this is an 
important code readability issue, and it can get hard to track all of 
the nesting elements: (`{()q{}}`).

> --------------------
>
>...
>
> Bye,
> bearophile



More information about the Digitalmars-d-announce mailing list