jastrachan | 11 Mar 14:43 2005

Re: NULL and Strings

On 11 Mar 2005, at 13:16, Martin C. Martin wrote:
> John Rose wrote:
>> Formatted strings often have a need to specify some variation in the 
>> ways substrings are inserted.
>> This is true with SQL scripts, shell scripts, XML concrete syntax, 
>> and simple string construction.
>> (Briefly:  Do you add quotes and escapes according to the target 
>> language, or just insert willy-nilly?)
> It would also be great to have some control of formatting of numbers, 
> e.g. scientific vs. regular, number of digits/decimal points. 
> Specifying this is bizzrely verbose in Java.  It would be great if it 
> were concise in GStrings.

Hmm; anyone can take a GString and extract the static text and values 
out of it and do any kinds of formatting on them. (e.g. the Sql class 
which uses prepared statements as a rendering).

I wonder if that would do - just pass the GString into something to 
render it?

>> There is a syntax "$*x" partially implemented in the new parser, to 
>> cover at least some of these problems.
>> We haven't had time yet to fill out the rules, but it's clear there's 
>> a degree of freedom here which needs control.
> My only concern with this is terseness leading to a confusing syntax. 
> C's printf() is like that: to a newbie, or even to an experienced 
> person looking at an uncommon case, it's not exactly clear what 
> "%5.2g%%%s%0x" means.  That looks like the effect of a noisy phone 
> line with an old modem.
> But there's a value to tersness, so maybe that's an appropriate 
> tradeoff.

I hear you. Though * is used in scripting languages as a way of 
expanding values into lists/maps or parameter lists; so reusing it in 
other contexts would feel natural to groovers.