Skip to content
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

Dates API: Allow n * Dates.Minute etc. #13840

Closed
Tetralux opened this issue Oct 31, 2015 · 4 comments
Closed

Dates API: Allow n * Dates.Minute etc. #13840

Tetralux opened this issue Oct 31, 2015 · 4 comments
Labels
dates Dates, times, and the Dates stdlib module

Comments

@Tetralux
Copy link
Contributor

In reference to issue #13763, it occurred to me that it might be worth considering borrowing a couple of other features from Go which also relate to select statements. Namely:

  1. Add something like after(::Dates.Period) which yields a Channel which provides a single value after that period of time. Already exists in the form of Timers.
  2. Add the ability to multiply an Integer or AbstractFloat by a subtype of Dates.Period to get the number of seconds that duration represents, as a number or a TimePeriod object.
    e.g: 4 * Dates.Second => 4; 1.255 * Dates.Minute => 75.3

You would then, for instance, be able to do things like this: sleep(5 * Dates.Minute)

@malmaud
Copy link
Contributor

malmaud commented Nov 1, 2015

I'm not clear on what 1) and 2) are doing that the current Timer function and Dates function aren't already doing.

@Tetralux
Copy link
Contributor Author

Tetralux commented Nov 1, 2015

@malmaud
I concede that the Timer type does already implement the functionality I suggest. My mistake.

RE 2) however, it's a question of readability, and simplicity.
Consider: Timer(4.5 * Dates.Minutes) vs. Timer(Dates.Minutes(4) + Dates.Second(30))
One is cleaner, and clearer, than the other, and the brackets could be considered noise in code that already has a lot of brackets.
The closest thing we have to this at the moment is 4 * Dates.Minute(1), which floats cannot be used with.

Of course, if you wish to expressing an exact number of minutes and seconds is important, then 4.5 is not as ideal but in those situations you would still be able to use Dates.Minute(4) + Dates.Second(30).

It's really more of a style thing, than functionality.

@malmaud
Copy link
Contributor

malmaud commented Nov 1, 2015

Alright, maybe you could change the title of this issue to reflect that it's now about the Dates API.
I agree that something like that would be neat.
cc @quinnj who maintains the Dates code.

@Tetralux Tetralux changed the title [SUGGESTION] Asynchronous helpers Make Dates API clearer and simpler to use, and merging two Channels Nov 1, 2015
@Tetralux Tetralux changed the title Make Dates API clearer and simpler to use, and merging two Channels Make Dates API clearer and simpler to use, and overload merge for two Channels Nov 1, 2015
@Tetralux Tetralux changed the title Make Dates API clearer and simpler to use, and overload merge for two Channels Dates API: Allow n * Dates.Minute etc. Dec 9, 2015
@tkelman tkelman added the dates Dates, times, and the Dates stdlib module label Dec 9, 2015
@KristofferC
Copy link
Member

Closing as dup of #10449

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dates Dates, times, and the Dates stdlib module
Projects
None yet
Development

No branches or pull requests

4 participants