Just another example of missing string interpolation

Steven Schveighoffer schveiguy at gmail.com
Fri Oct 20 01:52:39 UTC 2023


On Thursday, 19 October 2023 at 23:45:19 UTC, Walter Bright wrote:
> On 10/19/2023 3:40 AM, Andrea Fontana wrote:
>> // Example
>> deleteFiles("/tmp/test.txt", "/tmp/old.txt");
>> deleteFiles(i"/tmp/$dirname/$file"); <-- ooops this will be 
>> expanded?
>
>
> It will be:
>
> ```
> deleteFiles("/tmp/%s/%s", dirname, file);
> ```
>
> And you'll probably get a message like:
>
> "Could not find /tmp/%s/%s"


You might get a message like:

```
Could not find `/tmp/%s/%s`
successfully removed directory and all files under `importantApp`
Could not find `tempfile.cache`
```

The point is that it's too easy to match to strings, compile, and 
do a completely unexpected thing. And yes, that's the major 
reason why 1027 is so bad.

-Steve


More information about the Digitalmars-d mailing list