Re: Thinking (again) about an Objective-C bridge
Bruce Hoult <[email protected]>
| Newsgroups | gmane.comp.lang.dylan.gwydion.devel |
|---|---|
| Message-ID | <CAMU+Ekx5S1BJgt+rHRZutgw+N8rBoGO8O0J6a3e=ToWK6vwgVA@mail.gmail.com> |
Ideally, what you want is: - grab the symbols for the method and additional argument names - convert to strings and concatenate - create a global variable with that name (prefixed) to hold the selector value. - add the var and string to a hash table (or generate code) to look up the selector value at program startup I don't think there's anything there that Dylan macros can't do. On Fri, Jun 14, 2013 at 3:07 PM, Bruce Mitchener <[email protected]>wrote: > One of the issues to solve in doing an Objective-C bridge for Dylan is how > to represent a method invocation on the Dylan side. > > In C, we have %call-c-function, which looks like: > > %call-c-function (?name:expression, #key ?c-modifiers:expression = "") > (?parameters:*) => (?results:*) > (?arguments:*) > end; > > In LispWorks, they use this sort of syntax: > > (invoke window "close") > (invoke box "setWidth:height:" 10 20) > > In ClozureCL, this is the syntax: > > (send w :set-alpha-value 0.5) > (send v :mouse p :in-rect r) > > In Python: > > anObject.modifyArg_andAnother_(arg1, arg2) > > Overall, I like the approach used by ClozureCL as it seems much more > natural and more like the Objective-C that one would see. They've also got > variants of sending to the superclass, sending when a structure is > returned, etc. Having the keywords and the arguments alternate makes it > nicely readable (much more so than the LispWorks example). > > In ClozureCL, a lot of the work is done by macros, but I don't think our > macros in Dylan are powerful enough to do the same work. So what can we get > away with? We don't want a lot of work being done at run-time as we'd like > for this to be as efficient as possible. > > My thinking is that we might need a custom converter, much like > %call-c-function has, with the corresponding compiler support. I'd love to > be proved wrong though, so what thoughts do any of you have on this? > > - Bruce > > > -- > This message has been scanned for viruses and > dangerous content by *MailScanner* <http://www.mailscanner.info/>, and is > believed to be clean. > _______________________________________________ > hackers mailing list > [email protected] > https://lists.opendylan.org/mailman/listinfo/hackers > > _______________________________________________ hackers mailing list [email protected] https://lists.opendylan.org/mailman/listinfo/hackers