<< Back to previous view

[CLJ-709] Add a way to test/detect promise objects Created: 09/Jan/11  Updated: 03/Sep/11  Resolved: 03/Sep/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Alan Malloy Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


I'd like a predicate to determine whether an object is a (promise). Currently promises are implemented as a reify of IFn and IDeref, meaning there is no meaningful superclass to test for. It seems to me the simplest solution would be to create an IPromise interface extending IDeref; then (defn promise? [x] (instance? IPromise x)) is a simple solution. Even an empty "tagging" interface for IPromise would do, but it might also be nice to add a delivered? predicate for promises so that it's possible to test whether they're delivered without blocking or catching the "multiple deliver" exception; that would make the IPromise interface more meaningful as well.

This is fairly simple stuff, so I'll start plugging away at a patch and hope nobody objects.

Comment by Alan Malloy [ 09/Jan/11 2:55 AM ]

Um, just noticed http://dev.clojure.org/jira/browse/CLJ-680 but I don't know how to close this issue as a duplicate of that one. The only thing his patch doesn't have that I'd like is:

(defn promise? [x] (instance? IPromiseImpl x))
(defn has-value? [^IPromiseImpl x] (.hasValue x))

Comment by Chas Emerick [ 03/Sep/11 10:05 PM ]

Closed per request from Alan Malloy.

Generated at Sun Jan 21 10:53:46 CST 2018 using JIRA 4.4#649-r158309.