Description
Currently
julia> width(Date(1980,1,1)..Date(1980,1,10))
9 days
julia> width(1..10)
9
which makes sense in some contexts, but in others 10
would be a better choice (eg duration of a spell represented by the interval).
I would like to initiate discussion on how to handle this. The following come to mind:
-
Encourage the user to redefine
width
with+1
or equivalent whenever that makes sense, but don't do this automatically. Problem:width(1.0..10.0) ≠ width(1..10)
if one redefines it. ForDate
and similar this would not be a problem. -
To implement 1. more elegantly, one can define a trait, eg
Date
would have the traitRepresentsDuration()
,width
would test for that, and add1
accordingly. The default would be not having this trait. Problem: same as above, advantage: user could inspect this behavior for generic types. -
Add another generic function, eg
span
, which adds1
whenever applicable. Again, with or without trait.
Thoughts?