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

Re: [sc-users] string formatting notation




On 22 Dec 2017, at 16:29, <brianlheim@xxxxxxxxx> <brianlheim@xxxxxxxxx> wrote:

See the f-string idea from Python linked by Stefaan above: https://www.python.org/dev/peps/pep-0498/

AFAICT that exact solution would work with no problem in SC. e.g.: f"That is some good ${expletive}". Variable-name immediately followed by a string literal (or literal of any kind IIRC) is currently ill-formed, so there is no contention with code that is meant to say

f = 3;
f "this piece”;

No contention, true. But this is adding a new convention for method calls. What’s our good general design guideline here? If that works then so should:

"That is some good ${expletive}”.f

If that works, then why doesn’t

squared 2.0

This alternative syntax doesn’t add much and means another thing to learn. Code combining both is messy and confusing.  f is also not especially clear as a method name.

Would this look up instance vars in the local scope?

I suggested the envir approach because it seems more straightforward that and because environments are already well supported and encouraged working strategy in SC.

S.