Re: [F-Script-talk] Questions and comments
Brought to you by:
pmougin
From: Philippe M. <pm...@ac...> - 2004-04-19 01:50:26
|
Thanks for your comments and your questions. Better than the spam we got recently on this list! > Okay, if no one else is asking, I have a couple of questions to put > out there (instead of spam). > > I'm playing with F-script nearly all the time. It's great fun...very > educational. > > But I do have these questions: > > 1) How do you remove an object (completely) from the sys workspace? > I've tried releasing them, but no. If I add NSWindow objects to the > workspace, I can't do saveSpace because NSWindows can't be archived > (freeze-dried), the error tells me. > An object is in the workspace if it is referenced by an F-Script variable or if it is referenced by an object which is in the workspace. This is why the workspace is usually a whole, complex, object graph. To remove an object from the workspace you have to make sure that it is neither referenced by an F-Script variables, nor by an object that is itself part of the workspace. For instance: > myWindow := NSWindow alloc initWithContentRect:(125<>513 extent:400<>200) styleMask:NSTitledWindowMask backing:NSBackingStoreBuffered defer:NO. > array := {1, 2, 3, myWindow} After executing these two instructions, I have two more variables in my workspace: myWindow and myArray. To remove the window from the workspace I have to make sure that it is no more referenced by the "myWindow" variable, and no more referenced by the array (because the array is itself part of the workspace). To do that I might execute: > myWindow := nil and > array removeObjectAtIndex:3 > 2) How do you display a sheet (say, an alert) in a window. I keep > getting: > > error: argument 3 of method > beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo: > must be a compact Block > > What is a compact block? And why must it be there? > A compact block is something of the form: #mySelector It is the way to represents selectors in F-Script. In Objective-C, you would use @selector(mySelector) to denote the same selector. Compact blocks are automatically mapped to Objective-C selectors when passed as arguments to methods. Objective-C has both object types and non-object types. For instance, in Objective-C, selectors are not objects. In F-Script, everything is an object. This is why we need to define this kind of mapping between Objective-C non-object types and F-Script objects. Note that compact block are named like this because they are instances of the Block class, and thus can be manipulated like regular blocks. > And these comments: > > It's frustrating not to be able to use Cocoa convenience methods like > NSMakeRect and NSMakePoint. The end experience is that drawing becomes > a lot different from Cocoa (probably more like Smalltalk.) The problem here is that F-Script let you invoke Objective-C methods, but not functions like NSMakeRect etc. This is not a design decision, but a current limitation of F-Script. BTW, you're right, the F-Script way of dealing with points and rectangles is more Smalltalk-like. > It's frustrating that the journaling/log of a F-Script session isn't > saved between sessions. What's the point? I suppose you refer to the fact that the journal is reset when a new session begins. Well, I used the journal a lot, when developing the first versions of F-Script, as a way to record what I was doing in order to have that information when F-Script crashed. But your idea to keep the old records is interesting. Best, Philippe Mougin > I sure could use some examples of how to work with NSMatrix or NSCells > using F-Script's matrix orientation. > > Thanks for any enlightenment... > > --jcburns |