On 29/07/13 18:26, Masklinn wrote:
I don't have much to say, but

On 2013-07-29, at 06:24 , Alex Crichton wrote:
  * Any argument can be selected (0-indexed from the start)
keyword/named selection is *really* great for longer/more busy patterns,
it makes format string much more readable both in-code and for
translators (who usually lack part of the context, even with comments,
especially if they are non-technical). I think this is one of the great
strengths of Python's string formatting (both C-style and C#-style) or
Ruby's string interpolation, and if the formatting language is going
to be reworked away from C-style formats it would be nice to include
it if possible.

I don't think it can be integrated directly into the current grammar
though, as there'd be ambiguity with the function spec.
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

fmt! is a syntax extension (which receive their arguments as tokens, not at all parsed), so it can actually "define" its own syntax for named arguments, without any modifications to Rust's grammar (as long as it tokenises), so some or all of

   fmt!("{foo}", foo)
   fmt!("{foo}", foo=bar)
   fmt!("{foo} {bar}", let (foo, bar) = baz)

could be made to work; although, `foo = bar` is a valid expression (with return type ()), so it might be suboptimal to change its behaviour here. The `let` form allows for pattern matching in fmt! args, and still allows the fmt! implementation to have a simple parser.

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to