From: Wolfgang T. <wol...@gm...> - 2006-11-12 21:58:25
|
On 11/11/06, David Christensen <dw...@dw...> wrote: > Of particular note, I believe that I had to export the info_drawRect > in the $(exportClass) directive in order for the Cocoa system to be > able to call the haskellized replacement function. That used to be the case, now you need to use 'drawRect instead of info_drawRect. On 12-Nov-06, at 1:39 AM, Joe Jones wrote: > 1) (Serious newbie q) What does the # stand for? I haven't seen that > yet in what I have read. The # operator is defined by HOC as follows: object # message = message object A selector in HOC is just a function that takes the target object as its *last* argument, and # is just a way to make things look more object-oriented. > 2) For the general audience: Is there any way to make the getIvar code > (obj #. var = obj # getIVar var) disappear? This appears in every > class and seems like something that could be part of a base class, or > part of the template definition (note that I have no idea how the > template stuff works so...). David already answered this; a related question: should this convenience function be included in the HOC library itself? Currently, the "official" HOC way to access instance variables are the getIVar and setIVar functions. The #. operator is shorter, but breaks the symmetry between getIVar and setIVar. > 3) In general are all of the NSXxxx functions in > Cocoa/Foundation/AppKit prefaced with nsXxxx in Haskell? In general, yes. It is always possible that the HOC interface generator failed to parse a function declaration in Apple's header files and therefore left it out altogeter. Should that have happened to a function that you need, give me a shout on the mailing list. On 12-Nov-06, at 3:09 AM, Joe Jones wrote: > OK, I had to remove the NSView. prefix from the bounds call to get > that line to compile. However, the next line tells me that : > > EPView.hs:20:30: Not in scope: `set' Again, David already answered this, but this is what you get when I start writing an answer, then go do something else before finishing it. I would hate to have to throw it away, though: First, as a newcomer to Haskell, make sure you understand about Haskell's module system. Read up on import, import qualified, import qualified A as B etc. There are many methods by the name "set" in Cocoa. Not all of them have the same type signature, so they cannot be represented by just one function definition in HOC. When there are several different selectors by the same name, none of the selectors is exported by the top-level module Cocoa. We have to use the module system to disambiguate between the different "meanings" of the word "set" in Cocoa. For example, Cocoa defines: + (id) set; in class NSSet, and: - (void) set; in class NSColor. So, the word "set" could refer to either of those selectors, with a different type signature. To use them, we have to do something like this: > import Cocoa > import qualified Foundation.NSSet as NSSet > import qualified AppKit.NSColor as NSColor > > ... > > foo myColor = do > mySet <- _NSSet # NSSet.set -- objective C: mySet = [NSSet set]; > myColor # NSColor.set -- objective C: [myColor set]; > return mySet Note that HOC's module names follow Cocoa's header file names, not Cocoa's class names. Cheers, Wolfgang |