It could be that actually the *realized?* docstring needs change or clarification because a future can be realized in one of two ways: a value or a failure. Both count as realized in the sense that they are the *outcome * of the future; in other words, *realized?* evaluating to true* *gives the crucial guarantee that *deref* won't block. The pitfall lies with the assumption that a future can only realize into a value.
On Tuesday, February 19, 2013 7:13:41 PM UTC+1, Alex Nixon wrote: > > Hey Peter, > > On 19 February 2013 17:55, Peter Taoussanis <ptaou...@gmail.com<javascript:> > > wrote: > >> Hi Alex, >> >> This is a problem because the print-method multimethod implementation for >>> clojure.lang.IDeref assumes that if the .isRealized method returns true, >>> it's safe to deref the instance. >>> >> >> That's interesting. I've run into the case before where a cancelled >> future was throwing an exception on print, and certainly found it quite >> strange. Didn't think to look into it. This must be a bug, surely? >> > Yeah it does seem like a bug to me. > > Firstly, I think the mismatch between the clojure.core/realized? docstring > and the clojure.core/future implementation of isRealized should be fixed. > This could prevent the exception being thrown when printing futures. > Secondly, I think it'd be nice if print-method was aware of futures (as it > is agents), and printed the exception or :cancelled, if that's the future's > state (and possibly the same for delays too; it seems strange to say print > ":pending" when they aren't). > > -- > *Alex Nixon* > > Software Engineer | SwiftKey > > *al...@swiftkey.net <javascript:>** | http://www.swiftkey.net/* > > ++++++ > WINNER - MOST INNOVATIVE MOBILE > APP<http://www.swiftkey.net/swiftkey-wins-most-innovative-app-at-mwc> > - GSMA GLOBAL MOBILE AWARDS 2012 > > Head office: 91-95 Southwark Bridge Road, London, SE1 0AX TouchType is a > limited company registered in England and Wales, number 06671487. > Registered office: 91-95 Southwark Bridge Road, London, SE1 0AX > -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.