Voting: std.logger

Marco Leise via Digitalmars-d digitalmars-d at puremagic.com
Mon Sep 8 05:45:02 PDT 2014


Am Mon, 08 Sep 2014 11:17:48 +0000
schrieb "Robert burner Schadek" <rburners at gmail.com>:

> On Saturday, 30 August 2014 at 02:16:55 UTC, Dicebot wrote:
> >
> > ==============================
> > Martin Nowak
> > ==============================
> >
> > "Support duck-typing for the log functions.
> > Logger should be a concept and log functions should be 
> > free-standing
> > UFCS functions that take any `isLogger!T`.
> > To support a global `defaultLog` variable, you could add a 
> > Logger
> > interface and a loggerObject shim. See
> > http://dlang.org/phobos/std_range.html#inputRangeObject for 
> > this a pattern."
> >
> > Neither seem to be addressed nor countered.
> 
> Overly complicated IMO

This may sound surprising, but I believe if we want to make
Phobos consistent and give no incentive to roll your own
stuff, we should do this for a lot of APIs. Without going into
depth (but we could) there are good reasons to use classes and
there are good reasons to use duck typing structs.
Another API where this mixed scheme would apply are streams.
By using function templates with `if (isLogger!T)` and an
abstract class Logger, it will only get instantiated once for
all derived classes reducing template bloat, while allowing
custom instantiations for logger structs to avoid virtual
function calls or GC issues. So I agree with Martin.
It is a great way to bring the two camps together without
major casualties.

-- 
Marco



More information about the Digitalmars-d mailing list