diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-10-11 23:05:16 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-10-11 23:05:16 -0700 |
commit | 2cda9b946d701faa308b0915c83ea48fb94d94af (patch) | |
tree | a546879daba90dfd65fc370ab1e03475f7778d77 /stdlib | |
parent | aa02bc7f31edabb9e09f9756d7ae8fbc41995017 (diff) | |
download | txr-2cda9b946d701faa308b0915c83ea48fb94d94af.tar.gz txr-2cda9b946d701faa308b0915c83ea48fb94d94af.tar.bz2 txr-2cda9b946d701faa308b0915c83ea48fb94d94af.zip |
structs: optional init-exprs now useful in :delegate
* stdlib/struct.tl (:delegate): Handle the two-element
form of the optional parameter, which specifies the
usual initializing expression for the default value.
This is just passed through as-is to the generated
method. Diagnose if the three-element form occurs.
* tests/012/oop.tl: Some new tests.
* txr.1: Documented.
Diffstat (limited to 'stdlib')
-rw-r--r-- | stdlib/struct.tl | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/stdlib/struct.tl b/stdlib/struct.tl index d373c330..10b07710 100644 --- a/stdlib/struct.tl +++ b/stdlib/struct.tl @@ -427,9 +427,19 @@ (pp (new (fun-param-parser (cdr params) form))) (opt pp.(opt-syms)) (args (append pp.req opt pp.rest))) - ^((:method ,meth-name (,obj ,*pp.req - ,*(if opt (cons : (mapcar (lop list :) opt))) - ,*pp.rest) + ^((:method ,meth-name + (,obj ,*pp.req + ,*(if opt + (cons : (collect-each ((o pp.opt)) + (tree-case o + ((sym) ^(,sym :)) + ((sym init) o) + ((sym init sym-p) + (compile-error form + "~s: three-element optional \ \ + parameter ~s not supported" + o)))))) + ,*pp.rest) (qref ,delegate-expr (,target-method ,*args)))))) (define-struct-clause :mass-delegate (:form form self-var delegate-expr |