AbstractNamespace >> #removeSubspace:

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

AbstractNamespace >> #removeSubspace:

S11001001
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
[hidden email]--2007-nocandy/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  <[hidden email]>

        * 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
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: AbstractNamespace >> #removeSubspace:

Paolo Bonzini
Stephen Compall wrote:
> 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:.

Applied, thanks.

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk