On Thursday, 19 October 2023 at 07:51:38 UTC, Walter Bright wrote:
>On 10/19/2023 12:29 AM, Andrea Fontana wrote:
> > >is prone to errors
Well, you know, even you posted a wrong example earlier in the thread.
The error won't result in anything other than oops there's a format string in the output.
If that's the only prone-ness to errors, it's doing very well.
>I'm also somewhat concerned about potential error messages that might confuse users due to the non-obvious abstraction: f.e. what happens if someone writes myfunction(i"hello $name!");
Do you mean someone accidentally prefixing with 'i'? How would that be any different from the other proposal?
Not by mistake, but intentionally because I want to pass a formatted string to my function.
And if I'm not mistaken, that string will be expanded into a tuple that could mess up the call to my function, returning an error that might confuse the user. In the worst case, it could call my function with extra parameters I didn't even expect, causing some unexpected side-effects.
// This function delete all the file passed (just a joke)
void deleteFiles(string[]... files) { ... }
// Example
deleteFiles("/tmp/test.txt", "/tmp/old.txt");
deleteFiles(i"/tmp/$dirname/$file"); <-- ooops this will be expanded?