Don't forget, in some cases it's simply enough with ::, for instance (pop (:: classVar)). Just to make the discussion complete :-)
/Henrik On Wed, Dec 9, 2009 at 7:53 AM, Alexander Burger <a...@software-lab.de> wrot= e: > Hello Cle, > >> Now I have detected the class variables I want to use now. But the >> question raise, how to update a class variable? >> ... >> But for update, I only came up with this ugly code: >> >> =A0 =A0(with '+aClass >> =A0 =A0 =A0(=3D: ClassVar "new value")) > > 'with' is - in terms of processing - indeed a little overkill, as it > does an extra binding of 'This'. > > In terms of "beauty", there are not many options, though. I would use: > > =A0 (put '+aClass 'ClassVar "new value") > > and perhaps write a utility function. > > > >> And another question in that context: how can I get the class of an >> instance usable for (with)? If I try >> >> =A0 =A0(with This ...) >> >> I have to send the method to the class directly and not via an instance. >> However if I try >> >> =A0 =A0(with (car (type This)) ...) >> >> I can use this only within a method send to an instance, but not if send >> to the class directly! > > Yes, it depends on 'This' being bound. > > BTW: There is no such thing as "the class" of an instance. There is > always a list of classes. (car (type This)) might not be the right > class, the "main" class is usually (last (type This)) while the other > classes in the list are usually "prefix" classes. > > >> The only way I found working reliable (use class regardless if in a >> method send to a class or an instance) seem to be > > Note that in picoLisp there is no formal difference between objects and > classes. Objects may have local method definitions, and classes have > instance variables. So it just depends on the context, and on what the > programmer has in mind, if a symbol is regarded as an object or as a > class. > > >> =A0 =A0(with '`*Class ...) >> >> Is this the correct way, or did I overlook something? > > I'm not sure I completely understood what you want to achieve. This is > correct, if you want to capture the current class. Again, you could also > simply use 'put' here. > > Cheers, > - Alex > -- > UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=3dunsubscribe > -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe