From: Gary Wright Date: 2008-02-17T06:05:29+09:00 Subject: Re: object specific methods and id On Feb 16, 2008, at 3:30 PM, UpsNDowns wrote: > Alas, my problem now is, that an assignment for my CS class > requires me to prove that the obj is an instance of the singleton. > (And no, it's no trick question, the teacher has even lectured > about it and proposed a solution at the labs--- which btw I don't > buy). Well, prove the teacher wrong showing that their definition of 'instance of' is ambiguous. You could take a test driven approach and write some tests that describe the expected behavior of a class and its instance. Then try the tests against different types of objects: class/instance singleton-class/instance I'll bet you find that there are some tests that work with class/ instance that won't work with singleton-class/instance but that the tests that the teacher suggested work for both cases. > Pretending to be the devil's advocate, this could be explained away > (I *guess*) by claiming that the singleton class could have > provided a masking implementation of the class method. I suppose but then you have to explain why the singleton class didn't provide a masking implementation of its own superclass method, which you don't want it to do since that would break various other semantics in particular the behavior of singleton classes of classes and method lookup on class instances. > I would say this much though: The singletons are fuzzy, (the slides > from David Black ignores and belittles the importance of the > implementation, and dare I say the principles behind them). Well, there is an unresolved issue from Matz perspective. The core idea is the notion of per-object methods. That idea is currently implemented via the singleton class mechanism but, as we've discovered, somewhat awkwardly with respect to the normal inheritance hierarchy. Within the language itself, there isn't even a 'name' for the construct since it is only accessible via an expression: (class <