Time is a flat circle.
On Monday, November 10, 2014 2:24:09 AM UTC-6, John Myles White wrote: > > Yes, the use of zero is an anachronism from a design in which zero was > used to have a default value for arbitrary types. > > -- John > > On Nov 10, 2014, at 8:22 AM, Ivar Nesje <[email protected] <javascript:>> > wrote: > > Basically this is an issue with DataFrames using a function in base for a > different purpose than its documented intent. zero() has been documented > to mean additive identity > <http://docs.julialang.org/en/latest/stdlib/base/#Base.zero>, and Date > and DateTime, doesn't have an additive identity. (apart from the period > types, but it is unclear which one to return) > > Looking at dataframes, I discovered that they already monkey patch > Base.zeros() to make it work for strings > <https://github.com/JuliaStats/DataFrames.jl/blob/211cd659cb7f9035980697f7effa081e29b9bf3e/src/dataframe/dataframe.jl#L805> > . > > I think this is a bigger issue to be discussed in the contest of the use > case in DataFrames. My two obvious suggestions would be to: > > 1. Change the documentation for zero() to say that it is the additive > identity unless it doesn't make sense, in which case any default value is > good. > 2. Create a new function in Base for this specific need of a default > value. > > Ivar > > kl. 03:53:43 UTC+1 mandag 10. november 2014 skrev Jacob Quinn følgende: >> >> Hmmm........I guess we could add 0 and 1 definitions if it'll be >> generally useful (i.e. Date/DateTime s are ordinals with numeric-like >> properties, so being able to define zero/one and have them work with >> generic functions). >> >> It still just seems a little weird because there's not a real solid >> reasoning/meaning. I think one reason a lot of other languages define a >> zero(::DateTime) is because values can be "truthy" or "falsey", so you >> would compare a date with zero(::DateTime) to check for falseness. In >> Julia, you have to use explicit Booleans, so that's not as important a >> reason. >> >> Happy to hear other opinions/use cases from people though. >> >> -Jacob >> >> On Sun, Nov 9, 2014 at 9:23 PM, Thomas Covert <[email protected]> wrote: >> >>> To your first question, I'm sure there are good reasons for not having >>> zeros in the Date and Time types, but in other languages (i.e., stata), >>> dates and times are stored as integers or floats with respect to some >>> reference time. So, I *think* the 0-date in stata refers to January 1, >>> 1960. Obviously this is fairly arbitrary, but there is some precedence for >>> it in other languages. >>> >>> On Sunday, November 9, 2014 8:17:04 PM UTC-6, Jacob Quinn wrote: >>>> >>>> What Date would represent zero(::Date)? Or one(::Date), for that >>>> matter? Doesn't seem like a particularly useful definition. What's the use >>>> case? >>>> >>>> On Sun, Nov 9, 2014 at 9:14 PM, Thomas Covert <[email protected]> >>>> wrote: >>>> >>>>> I'm using Dates.jl on 0.3 and have discovered that there is no zero >>>>> defined for the Date or DateTime types. Is this intentional? >>>>> >>>>> >>>>> >>>> >> >
