Alternate syntax for field access/method calls
Dominique Boucher
dominique.boucher@nuecho.com
Sat Jan 15 13:41:00 GMT 2005
Chris,
> For myself, I use namespaces 99% of the time. So instead of:
>
> > (invoke (invoke someObject 'method1) 'method2 a b)
>
> I write:
>
> (define-namespace class1 <com.merced.SomeClass>)
> (define-namespace class2 <com.merced.SomeClass2>)
>
> (class2:method2 (class1:method1 someObject) a b)
>
> You can also do this if it's more convenient:
> (com.merced.SomeClass2:method2
> (com.merced.SomeClass:method1 someObject)
> a b)
Agreed. I also use namespaces a lot, as well as the latter technique (but
not
as often, since it's so verbose). But if my variables are already typed,
it's a shame
having to "type" the method calls too, IMHO:
(define (f (someObject :: <com.nuecho.SomeClass>))
(SomeClass:method1 someObject))
(define (f (someObject :: <com.nuecho.SomeClass>))
[someObject (method1)])
Also, for classes defined using "define-simple-class", the namespace thing
is not
as convenient since I have to put the fully qualified name of the class, not
simply the
class name. So I have to write:
(module-name <com.nuecho.mypackage.mymodule>)
(define-simple-class <AClass> (<Object>) ...)
(define-namespace classA <com.nuecho.mypackage.AClass>)
And this works only if the module is compiled...
Regards,
Dominique
More information about the Kawa
mailing list