CONSTRUCTOR: inherit2 ( a -- obj ) ;
[ T{ inherit2 f f 100 } ] [ 100 <inherit2> ] unit-test
+
+
+TUPLE: inherit3 hp max-hp ;
+TUPLE: inherit4 < inherit3 ;
+
+CONSTRUCTOR: inherit3 ( -- obj )
+ dup max-hp>> >>hp ;
+
+AUTO-CONSTRUCTOR: inherit4 ( -- obj )
+ 10 >>max-hp ;
+
+[ 10 ] [ <inherit4> hp>> ] unit-test
:: define-auto-constructor ( constructor-word class effect def -- )
constructor-word class effect def (define-constructor)
- class superclasses [ lookup-initializer ] map sift
+ class superclasses [ lookup-initializer ] map sift reverse
'[ @ _ [ execute( obj -- obj ) ] each ] effect define-declared ;
: scan-constructor ( -- class word )