On the document, it tells me I cannot comment on it. Wasn't the
ability to comment on the proposals one of the goals? Also, I can only
see the document embedded (maybe I'm missing something?), which is
rather uncomfortable.
I do have some comments. I'll wait to see if I should make them here,
or if I should do them on the document.
--
Daniel C. Sobral
I travel to the future all the time.
Thanks. I'm afraid I got carried away with the comments... :-) This
new proposal is vastly superior to the first one.
Agree, my reaction exactly. This is marvelous. (And as an old Lisp
hand, I love the macro/quasiquote example.)
{ is of course nicer than \{ nearly all the time, but the JSON use
case gives me pause. See Benjamin Jackman's comment. I wish I had an
idea on this, but I don't.
--
Seth Tisue | Northwestern University | http://tisue.net
lead developer, NetLogo: http://ccl.northwestern.edu/netlogo/
Implicits are in scope. See, this works just like for-comprehension
expansion: you rewrite the code as indicated, then process using
standard Scala rules.
That's why it is extensible. You can add methods to StringContext
implicitly. You can add show implicitly. You can add formatted
implicitly.
And note that "id" does *not* need to receive parameters. Pay close
attention to the XML example, and how it works. That's the example
that really brought to me the full impact of the proposal.
> And if there were a way to pass formatting information, that would be even
> better--maybe something with automatic deconstruction of tuples? I haven't
> had time to come up with something elegant and general.
Err? Beyond { expr ; fmt } expanding to expr.formatted("fmt")? What
else would you need?
>
> --Rex
>
> On Thu, Oct 27, 2011 at 9:28 AM, martin odersky <martin....@epfl.ch>
> wrote:
>>
>> I just augmented my string interpolation proposal with an alternative
>> syntax and mechanism. I like the alternative better because it is far more
>> general than the first proposal.
>> Comments welcome!
>> -- Martin
>>
>
>
--
> And if there were a way to pass formatting information, that would be evenErr? Beyond { expr ; fmt } expanding to expr.formatted("fmt")? What
> better--maybe something with automatic deconstruction of tuples? I haven't
> had time to come up with something elegant and general.
else would you need?
Oh, God, you're right! Sure, { x; 2.2f } looks nicer than { x; "2.2f"
}, but, in practice, you're quite likely to need a formatting computed
at run-time! Please, do comment this on the SIP.
> And if there were a way to pass formatting information, that would be
> even better--maybe something with automatic deconstruction of tuples? I
> haven't had time to come up with something elegant and general.
Maybe sub-expression ? Some standard library ?
Implicit cast to one of formatter classes, which result in string
expression instead of integer?
From s"I ate {n} apples" to like s"I ate {n.format.base(16)} apples"
One more thing is parameters reordering. Natural words order is different
in languages.
Say, in English it is adjective-noun but in Latin/French/Spanish/Italian
it is noun-adjective.
"Living water" or "aqua vita"
If translating any long enough text from English to Russian you found that
either you end with some Frankenstein of language, or you need to reorder
even subclauses in complex sentences.
One more example would be address, should it be ordered from {apartment
No} to {street} to {city} up to {country} ? Or from {country} down to ...
{apartment No} ?
While C sprintf-like specification - template string with placeholders,
followed by array of values - is harder to type and read, it allows
reordering on localisation, without changing program sources.
To integrate GetText-like functionality with StringContext(strings
list).method(valus list) it seems like intermediate layer like
StringContext(strings
list).localizer-and-reoderer(locale-info).method(values list) is required,
but injecting it after JARs are made is not so nice, as to have it in
place already.
--
Написано в почтовом клиенте браузера Opera: http://www.opera.com/mail/
> location in an expression anyhow? Just brainstorming.
If just brainstorming... function(Unit) aka call-by-name
{expression; yet expression; still expression; => now format}
> Maybe something other than ; there, perhaps just a normal ','
if to treat it like normal infix method AnyVal => string
{{val a = 7; a*a+a} infix-format 000d }
What are possible symbols not yet taken for one or another operator ? :-)
That would made typing longer, but then format specifiers no more are
special case