[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Objective C To Dylan



I am working on a Dylan wrapper for a set of Objective-C classes. I'm 
not an Objective-C expert so I need help with a couple of problems.

1. Classes vs. Protocols.

Classes and protocols have separate namespaces in Objective-C. Both 
protocols and classes may have methods. Both protocols and classes may 
adopt protocols. It is not uncommon for there to be a class with the 
same name as a protocol, and for the class to adopt the protocol. A 
class and a protocol of the same name may have different inheritance 
and methods and therefore different public interfaces.
It is possible to type id (untyped object) parameters by protocols, for 
example:

	id<MyProtocol>

will accept any object that conforms to MyProtocol, no matter what its 
class. MyProtocol may have the same name as MyClass but it may have a 
different interface and inheritance.

I can append "Protocol" to protocol names:

	<MyNameProtocol>

name protocols differently from classes:

	<-MyProtocol-> or @MyProtocol

or combine the interfaces of the protocol and class, giving a broken 
and mis-representative translation into Dylan.


2. Method Naming.

Objective-C methods use named parameters. For example:

[myObject param1: varA param2: varB];
[myObject param1: varC];

This can be represented well in Dylan using keyword parameters, but 
since keywords aren't used for choosing methods for dispatch, the above 
example gives a "multiple definitions" error because the two methods on 
the same object cannot be told apart.

I can number the methods, explicitly choose the "best" method to use 
when wrapping the code, or use non-keyword parameters.


Any suggestions gratefully received. The code I'm using to do the 
conversion is a simple Perl script so I can't do anything too fancy. :-)

Thanks.

- Rob.