Judging from previous discussions on this list, I get the feeling that
relying too much on the Java implementation details underlying the
public Clojure APIs is discouraged. This certainly makes sense
considering that apparently one of the future plans (no pun intended)
is to give the CLR and JavaScript ports of the language more focus.
IMHO this seems like a useful improvement. Maybe your proposal would
draw more attention if you backed it up with a patch -- even a
preliminary one? :-)
Your implementation points into the right direction (again, IMHO). I'd
like to offer two suggestions:
1. Leave out the three-arg version of future-await. The time unit
conversion seems somewhat superfluous, with little gain for the lines
of code added. Rich argued against writing thin wrappers around Java
stuff as well. And personally, I'd probably only ever use the two-arg
version with an integer in milliseconds, since that's what most
methods/functions are using anyway. (If you know of use cases for and
trust the system clock to act on milliseconds correctly, you could
also make the integer represent nanoseconds instead.)
2. Returning nil to represent timeout is dangerous here -- the future
may have completed correctly and returned nil! It should be perfectly
okay and idiomatic here to let the TimeoutException escape, as long as
you document this behaviour.
What do others think?
--
Daniel
Am 25.06.2010 um 20:48 schrieb Daniel Werner:
> On 25 June 2010 05:27, Ryan Senior <senio...@gmail.com> wrote:
>> (future-await fut2 2 :minutes) ; => "done"
>
> What do others think?
I agree – in particular for point 2.
For point 1: I think "2 :minutes" is not very clojure-like. It sound more like Ruby: 2.minutes. A more clojure-like approach would be to an use optional keyword argument.
(defn future-await
[fut & {:keys [timeout]}]
....)
(future-await zukunft)
(future-await zukunft :timeout time-out-in-ms)
Or of course the simple two-arg-version.
Sincerely
Meikel
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en