std.experimental.logger formal review round 3

David Nadlinger via Digitalmars-d digitalmars-d at puremagic.com
Sun Nov 2 10:42:18 PST 2014


On Sunday, 2 November 2014 at 18:29:09 UTC, Dicebot wrote:
> In my opinion inference is better choice for small building 
> blocks (like algorithms). For complete system like logging API 
> forcing @safe makes more sense as whatever its internals are, 
> exposed API should never be @system

This isn't about the library internals. These should be presented 
in a safe way, of course. The point here is that you restrict 
what your users can do by forcing templates to be @safe.

Imagine somebody has a type that cannot be @trusted because of 
whatever reason. Maybe because it's legacy code, maybe it uses 
resources it does not manage, … If you forcibly make logf @safe, 
then this type cannot be used with logf without some crazy 
workaround (simply using to!string might produce an unneeded 
allocation if the type uses the sink-delegate signature for 
toString).

Why not leave this up to the compiler and support more use cases 
without degrading the experience for @safe clients?

David


More information about the Digitalmars-d mailing list