ward-methods macro
It would be nice if we had a macro like methods but which worked
based on warding:
(define-values (buy-warden buy-incanter)
(spawn-warding-pair))
(define-values (sell-warden sell-incanter)
(spawn-warding-pair))
;; just an example, not claiming this is a good design
(define (^trading-booth bcom)
(ward-methods
[(buy-warden thing-to-buy money)
...]
[(sell-waden thing-to-sell how-much)
...]))
In that sense, "warding" becomes akin to the method itself, "incanting" becomes similar to "method invocation". One might even feel justified doing:
(define-values (buy-wmethod invoke-buy)
(spawn-warding-pair))
(define-values (sell-wmethod invoke-sell)
(spawn-warding-pair))
;; just an example, not claiming this is a good design
(define (^trading-booth bcom)
(ward-methods
[(buy-wmethod thing-to-buy money)
...]
[(sell-wmethod thing-to-sell how-much)
...]))
Of course, there's little difference here from multiply warded items.
A few things to note:
-
For synchronous,
$style warding, we can (and probably should anyway) do an optimization where we check the predicates associated with wardens in a loop before we dispatch. Maybe that should be a separate issue to support that though. Not sure. -
This gets much more message-heavy with the asynchronous
<-style warding approach. We can either fan out to all warding predicates to see if it looks like the object is locally warded (hmmm) or we can round trip a bunch until we get a confirmed match.
Thoughts?