DataAPI.jl icon indicating copy to clipboard operation
DataAPI.jl copied to clipboard

Change describe contract

Open bkamins opened this issue 4 years ago • 2 comments

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

bkamins avatar Nov 30 '21 22:11 bkamins

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)?

nalimilan avatar Dec 04 '21 15:12 nalimilan

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).

bkamins avatar Dec 04 '21 16:12 bkamins