[plt-dev] Reorganization of scheme/private/class-internal's initialization of object% and object<%>

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Wed Apr 29 11:05:31 EDT 2009

I'm trying to find place where initialization is at the top-level, but
doesn't have to be. There's an instance in the class system.

Here's a patch that hides it. It is tested. Anyone object to a commit?

Index: private/class-internal.ss
===================================================================
--- private/class-internal.ss	(revision 14649)
+++ private/class-internal.ss	(working copy)
@@ -2543,10 +2543,14 @@
 		  (make-struct-type name type 0 0 #f null insp)])
       make-))

-  (define object<%> ((make-naming-constructor struct:interface
'interface:object%)
-		     'object% null #f null #f null))
-  (setup-all-implemented! object<%>)
-  (define object% ((make-naming-constructor struct:class 'class:object%)
+  (define object<%>
+    (local [(define object<%>
+              ((make-naming-constructor struct:interface 'interface:object%)
+		     'object% null #f null #f null))]
+      (setup-all-implemented! object<%>)
+      object<%>))
+  (define object%
+    (local [(define object% ((make-naming-constructor struct:class
'class:object%)
 		   'object%
 		   0 (vector #f)
 		   object<%>
@@ -2571,17 +2575,18 @@
 		   (lambda (obj) #(()))        ; serialize
 		   (lambda (obj args) (void))  ; deserialize-fixup

-		   #t)) ; no super-init
+		   #t))] ; no super-init

-  (vector-set! (class-supers object%) 0 object%)
-  (let*-values ([(struct:obj make-obj obj? -get -set!)
-                 (make-struct-type 'object #f 0 0 #f (list (cons
prop:object object%)) #f)])
-    (set-class-struct:object! object% struct:obj)
-    (set-class-make-object! object% make-obj))
-  (set-class-object?! object% object?) ; don't use struct pred; it
wouldn't work with prim classes
+      (vector-set! (class-supers object%) 0 object%)
+      (let*-values ([(struct:obj make-obj obj? -get -set!)
+                     (make-struct-type 'object #f 0 0 #f (list (cons
prop:object object%)) #f)])
+        (set-class-struct:object! object% struct:obj)
+        (set-class-make-object! object% make-obj))
+      (set-class-object?! object% object?) ; don't use struct pred;
it wouldn't work with prim classes
+
+      (set-interface-class! object<%> object%)
+      object%))

-  (set-interface-class! object<%> object%)
-
   ;;--------------------------------------------------------------------
   ;;  instantiation
   ;;--------------------------------------------------------------------


-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://teammccarthy.org/jay

"The glory of God is Intelligence" - D&C 93


Posted on the dev mailing list.