Tree or graph shaped name spaces are not always easy to organize. The lobby and name inferencer in Self are nice, but here is an alternative I am trying : set intersection.
First we need a method to calculate the intersection of two sets. This is not a very good one, but it works:
traits set _DefineSlots: ( | $ aSet = ( | inter | inter: set copy. do: [ | :e | ( aSet includes: e ) ifTrue: [ inter add: e ] ]. inter size == 0 ifTrue: [ ^ nil ]. inter size == 1 ifTrue: [ inter do: [ | :e | ^ e ] ]. ^ inter. ). | )
Now we make some sets accessible from the lobby :
_DefineSlots: ( | nameSets* = ( | big = set copy. small = set copy. yellow = set copy. red = set copy. car = set copy. fruit = set copy. | ). | )
Place some objects in those sets :
big add: 1 yellow add: 1 car add: 1 small add: 2 yellow add: 2 car add: 2 big add: 3 red add: 3 car add: 3 small add: 4 red add: 4 car add: 4 big add: 5 yellow add: 5 fruit add: 5 small add: 6 yellow add: 6 fruit add: 6 big add: 7 red add: 7 fruit add: 7
Can you guess what the following give you ?
red red$car big$red$car big$fruit fruit
How can I get this ( useful, in my opinion ) effect with trees or graphs? What are the disadvanteges of this method ( besides performance ) ?