Next: Object reference predicates, Previous: Synchronous calls, Up: Objects [Contents][Index]
Like $
, but to-refr may be near or far, and
<-
returns a promise instead of a result.
(define object-a (spawn ^some-object)) ;; in a different vat... or the same; it doesn't matter to <- (define a-promise (<- object-a arg1)) (define b-promise (<- object-a 'some-method arg2))
<-
has a variant that does not return a promise:
Like <-
, but return void
instead of a promise.
(define object-a (spawn ^some-object)) ;; in a different vat... or the same; it doesn't matter to <-np (<-np object-a arg1) ; returns void (<-np object-a 'some-method arg2) ; returns void
Like <-np
, but only operate on far objects.
Respond to a promise, optionally with error handling. Return nothing
unless promise? is #t
, in which case return a promise.
As mentioned above, if #:promise?
is #t
, then on
will itself return a promise. This promise is resolved as follows:
vow
is fulfilled and fulfilled-handler
is not
provided, the promise returned will share vow
’s resolution.
vow
is broken and catch
is not provided, the promise
returned will share vow
’s broken result.
vow
is fulfilled and fulfilled-handler
is provided,
the resolution will be whatever is returned from
fulfilled-handler
, unless fulfilled-handler
raises an
error, in which case the promise will be broken with its error-value
set to this exception.
vow
is broken and catch
is provided, the resolution
will be whatever is returned from catch
, unless catch
raises an error, in which case the promise will be broken with its
error-value set to this exception (which may even be the original
exception).
;; in the context of some vat (define object-a (spawn ^some-object)) ;; in the context of some vat, possibly different (on (<- object-a arg1) (lambda (val) (some-proc val)) #:catch (lambda (err) (handle-err err)) #:finally (lambda _ (other-proc)) #:promise? #f) ; the default, written out for demonstration
You can also wait for the resolution of a promise without necessarily responding:
Wait for to-refr to resolve, then inform listener. If
wants-partial? is #t
, return updates rather than waiting
for full promise resolution.
Next: Object reference predicates, Previous: Synchronous calls, Up: Objects [Contents][Index]