print function

Artur Skawina via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Feb 4 10:29:03 PST 2016


On 02/04/16 18:53, ixid via Digitalmars-d-learn wrote:
> On Thursday, 4 February 2016 at 17:34:33 UTC, Artur Skawina wrote:
>> On 02/04/16 16:32, Artur Skawina wrote:
>> but that seems too expensive, when the use is just in toy programs and debugging.
> 
> I hadn't really considered the relative cost-benefit, it's just a habit to try to hardcode things at compile time. =) It certainly seems to make sense to do it that way.

Just to clarify -- *all* versions work at CT; the static-foreach
will be unrolled at CT, and the mixin argument will be fully
evaluated at CT too. The only difference is in a) readability, b)
the `write` template instantiations (and potential re-use).

Using the std lib `write*` templates has a huge cost; for any
kind of /real/ programs, that care about performance at all, they
are better avoided. (But it probably doesn't matter if you already
heavily rely on GC and don't print much, other than that they add
tons of code to the executable)


artur


More information about the Digitalmars-d-learn mailing list