[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] string formatting notation



> Since you said it’s not about typing I’d personally prefer something like "...".interpolate

For better or worse, it's impossible as a method call because of the nature of string interpolation; it requires new syntax elements of necessity. I think most people would prefer using a distinctive notation to express something that is syntactically distinct from a method call.

For comparison, this would be similar to having to type:

13F.hex;

for `13F` to be understood as a hexidecimal literal at compile-time. Now `.hex` looks like a method call, but is really a builtin postfix that changes the meaning of the literal preceding it.

> That’s nothing new, easier to understand and remember than f”...", and matches existing conventions and style.

SC's 0x and 36r are both existing conventions here. They are nifty brief prefixes that signal a literal (numeric) type and allow things to happen at compile-time that could only otherwise be done with invoking the interpreter at runtime. To a lesser extent you could also consider 3s to be part of this convention. Whether or not we think those are good language features is another story; I'm just pointing it out since you brought up the question of language style.

-Brian


On Fri, Dec 22, 2017 at 3:56 PM, <i@xxxxxxxxxxxxxx> wrote:

On 22 Dec 2017, at 21:38, <brianlheim@xxxxxxxxx> <brianlheim@xxxxxxxxx> wrote:

OK... but overall not a bad solution, right? Think of it as a string literal which makes itself amenable to idiomatic string interpolation. There would be no way to get real string interpolation with a method call.

I certainly agree it’s useful and adds something that people might miss from other languages.. Personally it still feels to me like new syntax, which makes me uncomfortable. Since you said it’s not about typing I’d personally prefer something like

“…”.interpolate;

That’s nothing new, easier to understand and remember than f”...", and matches existing conventions and style.

S.