]> gitweb.factorcode.org Git - factor.git/commitdiff
call initializers in reverse order to allow base classes to set state after slots...
authorDoug Coleman <erg@jobim.local>
Thu, 11 Jun 2009 18:19:54 +0000 (13:19 -0500)
committerDoug Coleman <erg@jobim.local>
Thu, 11 Jun 2009 18:19:54 +0000 (13:19 -0500)
basis/constructors/constructors-tests.factor
basis/constructors/constructors.factor

index bb63838f5dcdc2692b84d71457b2bf260d166fef..ae7fd0409c7fd69e03e6a8064a2e5e0bfc079411 100644 (file)
@@ -65,3 +65,15 @@ TUPLE: inherit2 < inherit1 a ;
 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
index 6fd6fa19064337b7d439827921fa5d0047dd70a8..a2c8d7637dd136256d72b094f035d400faa60b15 100644 (file)
@@ -50,7 +50,7 @@ MACRO:: slots>constructor ( class slots -- quot )
 
 :: 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 )