Re: [F-Script-talk] newbie questions
Brought to you by:
pmougin
From: Philippe M. <pm...@ac...> - 2006-06-19 21:00:47
|
Le 19 juin 06 =E0 16:25, Rainer Keller a =E9crit : > Hi all, > > I just found F-Script a few days ago and was going through the > tutorials and reading up what I could find. I also tried looking at > the list archives, but I get an error when I do that: > "Private archive file not found" Yes, the mailing list has recently suffered several problems =20 following a change of the underlying system. SourceForge, which is =20 operating the mailing list, has been made aware of the problem with =20 the archive and it should be fixed very soon now. > I did subscribe to the list and confirmed, so I think I am properly > registered. > > Now what I wanted to search for was creating classes, having an image > and a changes file. > > For creating classes at least for debugging and experimentation (aka > hacking ;) I thought it should be possible to create an Objective-C > class for the "Metaclass". Well, I am probably misunderstanding the > Metaclass concept still, but this is what I was thinking of: > Just a class with one member that has 2 NSDictionaries, one for the > members and one for the methods. make sure that it catches all > unknown methods which get sent to it and then looks them up in your > dictionary. Would that be possible? Yes. Actually the KFDecorator module adopts this kind of approach =20 (see http://homepage.mac.com/kenferry/software.html#KFDecorator). Note that F-Script also has a built-in experimental support for =20 creating classes (this functionality is implemented in the JGType =20 class). It uses the Objective-C runtime functions in order to create =20 "real" Objective-C classes on the fly. Here is a basic example where =20 we create a new subclass of NSObject, named MyClass, with three =20 instance variables named a, b and c, and define a simple method named =20= method1: > NSObject subclass:'MyClass' instanceVariableNames:'a b c' MyClass > MyClass MyClass > MyClass setFSBlock:[:self :_cmd| 'Method ' ++ _cmd ++ ' called on =20 ' ++ self printString] asInstanceMethod:#method1 > myInstance :=3D MyClass alloc init > myInstance method1 'Method method1 called on <MyClass: 0x4bb69c0>' There are several limitations in the current implementation: no =20 direct access to instances variables (you have to use KVC), no =20 support for calling super etc. > For having an image and a changes file there might be a conflict if > multiple interpreters are running, at least you would need to find > some logic, which I could probably look up in other Smalltalks. The saveSpace and loadSpace methods of the class System let you save =20 or load an entire workspace. Not really the same as an image, though. Best, Philippe > I thought somebody probably had these ideas and wishes before, but > didn't see anything on the website and had no luck with the list > archive. Could someone kindly give me a few pointers where to look or > point out why this is silly/won't work? > > Best regards! > Rainer Keller |