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

Re: Objective C To Dylan




Neelakantan Krishnaswami wrote:
> Rob Myers <robmyers@mac.com> wrote:
> >  On Thursday, October 24, 2002, at 10:00 PM, P T Withington wrote:
> > > On Thursday, Oct 24, 2002, at 16:40 US/Eastern, Rob Myers wrote:
> > >
> > >> 2. Method Naming.
> > >>
> > >> Objective-C methods use named parameters. For example:
> > >>
> > >> [myObject param1: varA param2: varB];
> > >> [myObject param1: varC];
> > >
> > > Wouldn't the 'C++' way be to name the methods:
> > >
> > > myObject$param1&param2 and myObject$param1?
> >
> >  This is true, and melange does something like this for struct field
> >  names if you don't ask it to shadow structs.
> >
> >  I did consider param1:param2:( myObject, varA, varB );, but I'm looking
> >  for something easy to remember and easy on the eyes for both Dylan and
> >  Obj-C programmers. If I was hoovering up methods before writing rather
> >  than just translating I could declare mangled names and map to them
> >  with macros, but I don't want to have to stay up that late. :-)
> 
> Generate the functions like that, and then use Bruce's suggestion to
> create a macro "objc" that expands like this:
> 
>  objc(x, param1: a, param2: b) ==> param1$param2(x, a, b)
> 
> That's only very slightly more verbose than the real objective-C
> method call syntax, and it looks good to a Dylan programmer.

 This would be a good place to have the macro extensions
that were mentionned by Fun-O folks a long while ago (sorry,
I don't remember who right now). Those allowed to create
#-prefixed macros with multiple kinds of brackets, with the
ability to use a procedural macro to parse and transform
the contents:

  #objc[myObject param1: varA param2: varB];
  #objc[anObject copy];

 I was fairly impressed by the capabilities this would bring
to Dylan. E.g., an in-language/in-compiler implementation
of a sqlj-like preprocessor #sql{ SELECT ... };, or the ability
to define more natural-looking pseudo-languages (#asm[ sum 0x4 ]),
without being tied to Dylan's syntax rules.

 Eric

-- 
Eric Gouriou                             egouriou@cup.hp.com