Thread: [F-Script-talk] newbie questions
Brought to you by:
pmougin
From: Rainer K. <dri...@ma...> - 2006-06-19 14:25:37
|
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" 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? 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. 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 |
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 |
From: Bryan W. <woo...@gm...> - 2006-06-19 23:15:45
|
I'm using F-script as the “underlying computation engine” for a application I’m working on. I've been able to make slight modifications to F-script’s behavior using Categories and poseAsClass: until now and I need some guidance. I need to intercept F-script’s variable lookup mechanism to catch whenever my special “range syntax” is used. That is, whenever variable a1_a12 is referenced I need to catch the lookup and invoke special code (that returns an array of variables a1 -> a10) because a1_a10 doesn't actually exist and is being used as a shorthand for this kind of behavior. I originally attempted to override -[FSinterpreter objectForIdentifier:found:] only to discover that the interpreter doesn't use that method internally. I then downloaded the source and found the existence of the SymbolTable class. Which brings me to my question: What SymbolTable method(s) should I override to do what I’m trying to accomplish? So far F-script’s integration with Cocoa/Objc has made making these kind of customizations a dream. I’m hoping that my luck continues. Thanks, Bryan |
From: Rainer K. <dri...@ma...> - 2006-06-20 11:42:19
|
Hi Philippe, > > Yes. Actually the KFDecorator module adopts this kind of approach > (see http://homepage.mac.com/kenferry/software.html#KFDecorator). Yep, I had found KFDecorator (sorry for not mentioning) but was missing a way to add member variables. But I hadn't seen JGType, thanks for the pointer! > > There are several limitations in the current implementation: no > direct access to instances variables (you have to use KVC), no > support for calling super etc. understood. But is there a reason that the KVC for the variable names and references to super could not be easily done in the compiler? Each F-Script class could have a base class, either an objective-C class or a previously defined Smalltalk class and two additional dictionaries for added member variables and methods. If you then hook into the compiler, KVC for the variables could be done automatically and super would be available as well. The compiler would just have to distinguish if it is still at the Smalltalk layer for resolving symbols or already at the boundary to Objective-C. Does that make sense? > > The saveSpace and loadSpace methods of the class System let you save > or load an entire workspace. Not really the same as an image, though. Yep, have found that as well (again sorry for not mentioning). But image and changes file would be shared between multiple open workspaces, changes would grow by both and in my mind the image would be part of the resources of the application (once modified probably stored in the users Library/Application Support folder and loaded automatically on app startup). Does anybody have an idea in which classes to look to get an idea how iamge and changes file are maintained for example in Squeak? > > Best, > > Philippe Thanks for the quick answer and pointers! Rainer |