Just another example of missing string interpolation

Steven Schveighoffer schveiguy at gmail.com
Fri Oct 20 20:10:51 UTC 2023


On Friday, 20 October 2023 at 19:58:44 UTC, Walter Bright wrote:
> On 10/20/2023 9:52 AM, Steven Schveighoffer wrote:
>> Just another whacked mole? What about the Exception problem?
>> 
>> ```d
>> throw new Exception(i"Invalid integer value in $file: $val");
>> ```
>
> You'll get an exception message:
>
>     Exception at FILE(LINE): Invalid integer value in %s: %s
>
> which is pretty much a nothingburger as a problem.

So you think it's a nothingburger to have zero idea where this 
exception was thrown from so you can figure it out?

e.g.

```
object.Exception at foo.txt(18446744073709551574): Invalid integer 
value in %s: %s
```

> YAIDIP can also call the wrong function if you're not careful 
> to make sure the right one is in scope.

Can you explain this? What function needs to be in scope?

> YAIDIP is also going to match any template that has a first 
> argument of type T with a weird struct that frankly few users 
> will know exists.

Yes, and it's possible the compiler can help out here, just like 
it says `string` instead of `immutable(char)*`

-Steve


More information about the Digitalmars-d mailing list