April 27 [Issue 24523] writeln doesn't memoize its templates | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24523 Steven Schveighoffer <schveiguy@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |schveiguy@gmail.com Resolution|--- |WONTFIX Severity|normal |enhancement --- Comment #1 from Steven Schveighoffer <schveiguy@gmail.com> --- Since write does exactly what is requested (loop over all parameters), it seems like the only "waste" here is a template instantiation of `write` with the particular parameters. Such a call is quite benign. See the code: https://github.com/dlang/phobos/blob/54eb95c139e09f6e7f8da3beed8407817ba184c1/std/stdio.d#L1750 And this also is going to result in extra instantiations of `write` (all the ones with single args). So in some cases, it may actually result in extra instantiations. In addition, splitting into multiple `write` calls is going to perform worse (and potentially cause weird outputs) as it locks and unlocks the underlying `File` for each parameter per call. Closing as wontfix. Now, there is a *runtime* penalty that is not discussed here. The fact that all the parameters need to be pushed again onto the stack, so you can add on the `\n`. If there was a better way to handle that, it might be useful to explore. Perhaps it's not worth fixing, because inlining might already do it. -- |
Copyright © 1999-2021 by the D Language Foundation