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

RE: More on dispatching by function return type



At 11:41 AM -0600 12/17/03, Kevin S. Millikin wrote:
>On Tuesday, December 16, 2003 7:29 PM, Dan Sugalski
>[SMTP:dan@sidhe.org] wrote:
>>
>>  I'm not sure CPS really has anything to do with it. CPS deals
>>  entirely with dispatching to and returning from (not that there's
>>  much difference) a function. Using the return type as part of the
>>  signature to determine which function to dispatch to seems orthogonal
>>  to how the dispatching actually happens.
>
>I think that the idea is that we're presumably familiar with static
>dispatch on argument types (both Java and C++ do this to resolve method
>overloading).  CPSing the program shifts the return type into argument
>position.

Well... no. Or at least it doesn't have to do so. If you wad up 
function lookup and dispatch into one big action and don't allow for 
out-of-band metadata to be passed in, then yeah, you shift the return 
type in as a parameter, but that strikes me as somewhat suboptimal.

It seems to me that determining which function to dispatch to and 
actually dispatching to it are separate operations, and as such can 
(and probably should) be split out. In that case CPS is entirely 
orthogonal to the signature based dispatching, as the signature of 
the function is used to retrieve the actual function to CPS dispatch 
to.

Things get rather more complex if you insist on a single generic 
destination for a particular function and require that destination 
function (or an intermediate step on the way to the function) to then 
look at the parameters and vector off appropriately. In that case 
then you do need to pass in the return type as a parameter, though I 
suppose you can tack it on the end with the hidden return 
continuation that's passed in, or it can be sent in as metadata on 
the function call.
-- 
                                         Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
dan@sidhe.org                         have teddy bears and even
                                       teddy bears get drunk