JuliaData / DataAPI.jl

A data-focused namespace for packages to share functions
Other
33 stars 13 forks source link

Change describe contract #43

Open bkamins opened 2 years ago

bkamins commented 2 years ago

Currently describe contract is that it does pretty print the passed object. The contract does not say what the function returns. I propose that describe should keep to print what it promises, but also return the computed statistics.

The crucial problem is that in REPL this would "double print" the contents. Also there is a duplication between describe and summarystats.

I am not sure what is best, but I leave this issue open to keep track of it.

CC @nalimilan

nalimilan commented 2 years ago

Maybe we could change describe(x) to return an object that supports show, but keep describe(io, x) = show(io, describe(x)) to limit breakage? How likely is it that somebody would rely on describe(x) printing the result directly to stdout, without ever printing the resulting object (which is currently nothing)?

bkamins commented 2 years ago

I agree that having describe(x) return nothing is not useful at all and kind of anti-pattern. I think this kind of behavior should be restricted to functions like print, show etc. whose only purpose is printing things (and I would not extend this list with describe).