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

Re: Q: member syntax in dylan?



Roland Paterson-Jones wrote:
> 
[snipped for nntp reasons]
> 
> Can you give an example where a call is dispatched elsewhere and the first
> argument is (exactly) a <class>. I can think of such examples where the
> first argument is a  proper subclass of <class>. Actually, I can probably
> think of one where dispatch is performed on at least 2 other arguments, but
> this is pretty contrived and such would certainly not want to use this sort
> of syntactic sugar.
> 
> I have the feeling that, most of the time, methods I write would be (in
> effect) single-dispatched on one (the first) argument.

This is what you think now :-)

More than often you will discover that multiple dispatch is the right hammer for your bunch of nails...

But seriously, there is a way to do what you want using a function-macro:

usage:

send(<function> => <object>)(arg1, arg2, ...);


(untested) macro def:

define macro send
  { send(?message:name => ?receiver:expression)
	=> { curry(?message, ?receiver) }
end macro send;


A clever compiler might optimize this as efficiently as you expect it to be.

Also conceivable is the -setter form, which I leave as an exercise :-)

Hope this helps,

	Gabor


> 
> Roland



Follow-Ups: References: