#lang liso ;; Read point.liso and regex.liso for uses of this module. provide: proxy define-proxy apply ;; I have not adapted struct, so it is a bit awkward to use; because ;; prop:procedure maps to (prop procedure), I have to use ;; #"prop:procedure" which is the syntax I chose to represent ;; arbitrary symbols (most Scheme implementations use |xyz|, but I ;; think #"xyz" is better). struct proxy: fn() #:property, #"prop:procedure" (p, args *) -> ;; used when the proxy is called normally proxy-fn(p)(args) obj msg = ;; this is like apply(obj, msg) = ... if proxy?(obj): then: proxy-fn(obj)(msg) else: racket-apply(obj, msg) define-syntax define-proxy: syntax-rules (): define-proxy defn: {pattern => expr, ...} => defn = proxy: match-lambda: {pattern => expr, ...}