[Openmcl-devel] Using Cocoa with MCL

Randall Beer beer at eecs.cwru.edu
Fri May 9 15:26:52 PDT 2003


>> As you
>> suggest, the latter may be implemented in former.  I guess that I'm
>> struggling to clearly envision what the final goal should look like, 
>> at
>> least in broad terms.  Then we can decide what the right intermediate
>> layers of abstraction might be.  Is the goal (1) Lisp sugar for ObjC,
>> (2) CLOSified Cocoa, (3) an MCL-like CLOS system, (4) something like
>> CLIM (or (5), something I haven't thought of)?
>
> What I'm thinking of as "the middle layer" might also be described
> as (1).  I think that it'd be a step up from the status quo; it'd
> make things like the demo IDE easier to write and (hopefully) easier
> for people to understand.  I don't know that CLOS needs to be too
> involved in things at this level.  This layer might wind up being
> similar to CLX or XLib in scope: it's possible to program in it,
> but it's also useful as a foundation for higher-level things (McCLIM
> and other things use CLX, GTK/GDK/GNOME and Qt/KDE use XLib.)
>
> One place where that analogy breaks down is that CLX and traditional
> Carbon are "toolkits", whereas Cocoa (and modern Carbon, to a lesser
> extent) are "frameworks" : the toolkits provide drawing primitives
> and event notification, while the frameworks additionally provide
> reasonable default behavior and a protocol for extending it.
>
> In something like MCL's window system, CLOS provides the framework
> on top of the Carbon toolkit.  What would/should CLOS provide for
> Cocoa ?

Here's a somewhat more fleshed-out example of what I had in mind.

;;; Class definition

@interface myObject : NSObject
{
     int count;
     NSTextField *textField;
}
- (void) increment:(id) sender;
@end

(defclass my-object (ns-object)
   ((count :type integer)
    (textfield :type ns-text-field))
   )


;;; Instance method definition

- (void) increment:(id) sender
{
     count++;
     [textfield setIntValue: count];
}

(defmethod increment ((o my-object))
   (progn
     (incf count)
     (set-int-value textfield count)))


;;; Object creation and initialization

[[NSAttributedString alloc] initWithString: @"A String" attributes: XXX]

(make-instance 'ns-attributed-string :init-with-string "A String" 
:attributes XXX)


;;; Invoking instance methods

[aDict setObject: anObject forKey: aKey]

(set-object-for-key aDict anObject aKey)

or perhaps (send aDict :set-object anObject :for-key aKey)


;;; Invoking class methods

[NSString stringWithString: @"Hello, world"]

(string-with-string (find-class 'ns-string) "Hello, world")

;;; Class method definition

(Not sure about this)


_______________________________________________
Openmcl-devel mailing list
Openmcl-devel at clozure.com
http://clozure.com/cgi-bin/mailman/listinfo/openmcl-devel



More information about the Openmcl-devel mailing list