interpolation proposals and safety

Adam D Ruppe destructionator at gmail.com
Fri Aug 30 15:21:49 UTC 2024


On Friday, 30 August 2024 at 14:36:56 UTC, Steven Schveighoffer 
wrote:
> Yes, I purposely said log, because that's the intention of 
> `writeln`.

Gonna disagree with this: writeln's intention is to write a line 
to the stdout stream. It has no more semantic knowledge; it is 
fundamentally a low level function with a wide variety of high 
level uses.

You can use it for logging to the console, but it might also go 
to a file, but it might also go to a user for interactive use 
("Enter your name: "), and it might also be structured output 
intended to be consumed by another program: ./yourapp | whatever.

CGI, on the low level, works as one of those unix pipelines. You 
ought to be more careful with that, but writeln has no idea how 
it is actually going to be used.

> For instance, what if you call a function that logs something 
> to the console? That gets included in your html.

They're supposed to use the stderr stream for that kind of thing, 
which is traditionally redirected to the server's log file.

But yeah, writeln is a low level function and you have to treat 
it as such - limiting what it is allowed to do can help one use 
case but hurt another, so that's hard to say... but at the same 
time, users really shouldn't be encouraged to use it. There 
should be high level intent libs that do those jobs all better 
and easier.


More information about the Digitalmars-d mailing list