-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
width of integer & similar intervals #21
Comments
How about |
Thanks for the suggestion, see PR #22. |
See discussion at #21, this should fix the issue.
We now have julia> duration(Date(1980,1,1)..Date(1980,1,10))
10
julia> duration(1..10)
10 |
Yes, definitely the units need to be preserved. And just to check (sorry, short on time), I think we got rid of |
Yes we got rid of If anything, the following is the most reasonable definition of length(d::AbstractInterval) = (@assert !isempty(d); ℵ₁) |
Currently
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?
The text was updated successfully, but these errors were encountered: