From 8357dd0ce75b5cace504acfcef2c31ee83a35e9c Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 17 Oct 2022 08:12:10 -0700 Subject: defstruct: new :inherit clause. The :inherit clause allows custom struct clauses to inject inherited bases. * stdlib/struct.tl (defstruct): Recognize :inherit clause, adding symbol arguments to extra list of supers that get appended to the list coming from defstruct's seconda rgument. (define-struct-clause): Disallow :inherit clause name. * tests/012/oop-dsc.tl: New tests. * txr.1: Documented. --- tests/012/oop-dsc.tl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/012/oop-dsc.tl') diff --git a/tests/012/oop-dsc.tl b/tests/012/oop-dsc.tl index c0b6068b..7885f386 100644 --- a/tests/012/oop-dsc.tl +++ b/tests/012/oop-dsc.tl @@ -63,3 +63,18 @@ [s3.b-hash 3].a "three") (call-finalizers s3) (test [s3.a-hash "one"] nil)) + +(define-struct-clause :s3 () + '((:inherit s3) + (:inherit passwd group))) + +(defstruct s4 (time) + (:s3)) + +(let ((s4 (new s4 a "x" b 999))) + (mtest + [s4.a-hash "two"].a "two" + [s4.a-hash "x"].a "x" + [s4.b-hash 999].a "x" + s4.uid nil + s4.gid nil)) -- cgit v1.2.3