[erlang-questions] Cocoa Erlang

Joel Reymont joelr1@REDACTED
Sat Jun 9 22:36:18 CEST 2007


Folks,

I'm trying to figure out how to most elegantly define Cocoa classes  
in Erlang. It's not a very declarative language so the only thing I  
can think of is creating some sort of a list and tuples structure to  
hold the field and method definitions.

Please let me know if you have any suggestions!

I'm including the original ObjC as well as the equivalent Scheme code  
using the excellent Chicken Scheme Cocoa bridge.

     Thanks, Joel

--- Original Objective-C ---

@interface ConverterController : NSObject {
   IBOutlet id dollarField;
   IBOutlet id rateField;
   IBOutlet id totalField;
}

- (IBAction)convert:(id)sender;
@end

--- Chicken Scheme ---

(define-objc-class ConverterController NSObject ((outlet: amountField)
                                                   (outlet: dollarField)
                                                   (outlet: rateField)
                                                   (outlet: converter))
    (- VOID ((convert: ID sender))
       (let* ((currency (@ @dollarField float-value))
              (rate     (@ @rateField   float-value))
              (amount   (@ @converter   convert-currency: currency
                                        at-rate: rate)))
         (@ @amountField set-float-value: amount)
         (@ @rateField select-text: self))))

--
http://topdog.cc      - EasyLanguage to C# translator
http://wagerlabs.com  - Blog








More information about the erlang-questions mailing list