Tuples, CTFE, and Sliding Template Arguments

Walter Bright newshound2 at digitalmars.com
Sat Jan 13 03:36:33 UTC 2024


On 1/12/2024 6:56 PM, Timon Gehr wrote:
> On 1/13/24 03:16, Walter Bright wrote:
>>
>> The other reasons:
>>
>> 1. preventing calls to functions passing an ordinary string as opposed to an 
>> istring tuple
>> 2. preventing nested istrings
>>
>> have already been addressed. The compile time thing was the only one left.
> 
> There is more, e.g.:
> 
> - You cannot interpolate an expression sequence, it will cause the format string 
> to get out of synch with the arguments.

I don't know what "interpolate an expression sequence" means. As for things 
getting out of sync, execi() with CTFE can reject a mismatch between format 
specifiers and arguments.

If you mean nested istrings, that can be simply rejected by not allowing a tuple 
argument for an argument. Or, execi() can detect arguments with the `Format` 
type and handle the nested istrings.


> - DIP1027's format strings allow manual overrides that may then be incompatible 
> with the library functions.

execi() with CTFE can reject them.


> - DIP1027's format strings require the user to manually escape e.g. '%s' so that 
> the library does not mistake it for a format specifier, even though the user 
> does not otherwise interact with format specifiers at all.

execi() with CTFE can automatically escape them.


More information about the Digitalmars-d mailing list