This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Alternate syntax for field access/method calls


> Dominique Boucher wrote:
> > 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,
> 
> I'm leary of "borrowing" square brackets for method calls.
> ...

First of all, let me apologize a bit. I realized I was a little harsh in my
wording. 

Also, it was not a request for changing or adding anything to Kawa. It was
only
a small experiment with readtables. I know a few (proprietary) Lisp systems
that
use the same [ ] notation. I simply wanted to know how easy it would be in
Kawa to 
emulate that. And I wanted to share this experience with other
users/developers.

That being said, I don't use BRL/KRL myself, and I never use square brackets
instead of parentheses (it's just a question of personal taste, I'm so used
to parentheses...).
So my own use of square brackets does not conflict with anything else.

And I do have another solution: a simple 'with' macro that implements the
same
expansion:

  (with object (method1) (method2 a b))

=>
  (invoke (invoke object 'method1) 'method2 a b)

It is particularly helpful if you write your methods in a Smalltalk way, by
always returning
(this) instead of returning void. In this case, it is much more convenient,
IMHO, to write

  (with object
   (start-a)
   (start-b)
   (stop-b)
   (stop-a))

Then, say,

  (A:stop-a (A:stop-b (A:start-b (A:start-a object))))

But maybe this sort of expression does not appear very frequently.

> > 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>)
> 
> Thanks to work funded by Merced, you should now be able to do:
> 
> (define-name classA <AClass>)

You are absolutely right. Since I don't use the latest version at work, I
forgot that idiom. 

Dominique



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]