I have use for a method that can remove namespaces similarly to their addition with addSubspace:, so I hijacked removeSubspace: (which doesn't seem to be used at all currently), changed its category, and gave it similar semantics to addSubspace:.

See attached, also at [EMAIL PROTECTED]/smalltalk--backstage--2.2--patch-8, which is against smalltalk--devo--2.2--patch-259.

--
Stephen Compall
http://scompall.nocandysw.com/blog
2007-02-09  Stephen Compall  <[EMAIL PROTECTED]>

        * kernel/AbstNamespc.st: Make removeSubspace: public, change its
        argument to be a symbol rather than a namespace, and don't make it
        a subspace of Smalltalk.

--- orig/kernel/AbstNamespc.st
+++ mod/kernel/AbstNamespc.st
@@ -321,6 +321,17 @@
       space notNil ] whileTrue
 !
 
+removeSubspace: aSymbol
+    "Remove my subspace named aSymbol from the hierarchy."
+    | spaceName |
+    spaceName := aSymbol asGlobalKey. "as with primNew:name:"
+    self subspaces remove: (self hereAt: spaceName)
+                  ifAbsent: [SystemExceptions.InvalidValue
+                                 signalOn: aSymbol
+                                 reason: 'aSymbol must name a subspace'].
+    ^self removeKey: spaceName
+!
+
 selectSubspaces: aBlock
     "Return a Set of subspaces of the receiver satisfying aBlock."
     | aSet |
@@ -489,11 +500,6 @@
 
 setSubspaces: newSubspaces
     subspaces := newSubspaces
-!
-
-removeSubspace: aNamespace
-    self subspaces remove: aNamespace.
-    aNamespace setSuperspace: nil
 ! !
 
 
_______________________________________________
help-smalltalk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to