Adding a new module is not a breaking change. Why would it be?

Michał.

On 3 Aug 2017, 19:39 +0200, OvermindDL1 <[email protected]>, wrote:
> Considering it is a breaking change anyway, why not keep it in `Logger` but 
> just append `_lazy` to the existing functions, so `warn` has a `warn_lazy` 
> and so forth as well?
>
> I'm curious why logger guarantees execution of the argument anyway as almost 
> no logging library in any other language I've used guarantees that (as the 
> entire calls can vanish at compile time depending on settings).  Perhaps it 
> would be good to change the default style in Elixir 2.0 so that there are no 
> argument evaluation guarantees at all and postpone the changes until then 
> (people can just use functions until then)?
>
>
> On Thursday, August 3, 2017 at 10:17:04 AM UTC-6, Michał Muskała wrote:
> > Hello everybody,
> >
> > Elixir's logger is a solid library, it has one awkwardness in use, though. 
> > When logging data that might be expensive to produce (and arguably anything 
> > besides static strings is expensive to produce for logging), logger 
> > requires wrapping the content in a function.
> >
> > This is dictated by the fact that otherwise logger can't guarantee the 
> > argument to the logger macros will be evaluated, so it has to be explicitly 
> > marked as lazy. Unfortunately, while this solution is correct, it is quite 
> > awkward to use and makes the code less readable.
> >
> > I propose adding a new Logger.Lazy module with the same interface as the 
> > Logger module - and by that I mean all the debug, info, warn and error 
> > macros. The only difference would be in the fact that macros from that 
> > module, wouldn't give guarantee as to the execution of the argument of the 
> > log macros. This could be achieved by implicitly wrapping in a function or 
> > probably (and preferably) injecting the test condition directly into the 
> > call site.
> >
> > Introduction of a new module makes it extremely easy to use in new code 
> > (without needing to learn anything new or exploring new interfaces) and 
> > adding a separate module makes it possible to update old code extremely 
> > easily - all that's needed is change the line
> >
> >     require Logger
> >
> > into
> >
> >     require Logger.Lazy, as: Logger
> >
> > Michał.
> --
> You received this message because you are subscribed to the Google Groups 
> "elixir-lang-core" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/elixir-lang-core/28ed5856-ed06-47f7-a290-f9ee210e3b48%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/7c2d3646-fbcd-4d96-b95f-8491e0afb85b%40Spark.
For more options, visit https://groups.google.com/d/optout.

Reply via email to