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

re: df versus dm



"Brent Fulgham" <brent.fulgham@xpsystems.com> writes:

> Jonathan,
> 
> Some of us at LTU (http://lambda.weblogs.com) are puzzling over the
> difference between 'dm' and 'df':
> 
> ==========================
> Chris Rathman - Re: goo: a generic-function based OO language  
> 4/19/2002; 9:23:10 AM (reads: 7, responses: 0)  
>  
> Oh, and one other question. What's the difference between dm and df?
> Looks like one means define method and the other means define function.
> But I couldn't figure out any difference between the two.  
> ==========================
> 
> Based on my limited Dylan understanding, I posted this:
> 
> ==========================
> Brent Fulgham - Re: goo: a generic-function based OO language  
> 4/19/2002; 9:34:57 AM (reads: 1, responses: 0)  
>  
> I believe that "dm" means "Define Method" -- which generates what would
> be a regular function in the Scheme world.  "df" is "Define Generic
> Function", which uses Goo's multi-method dispatch using type information
> to select the closest method.

this is exactly like dylan, where df == "define function" and dm ==
"define method".  reading the dylan reference manual will greatly
clarify this (unless define function is not defined there but
otherwise its just a macro as shown below). 

not quite, df is define function (ala dylan), that is

  (df f (...) ...) === (dv f (met (...) ...))

meaning that f is bound to a particular regular function from the
scheme world, whereas, dm is define method (ala dylan), that is
approximately

  (dm f (...) ...) 
    === (seq (unless (bound? f) (dv f (gen (...) ...)))
             (add-met f (met (...) ...)))

although the details aren't quite there (and this assumes special
forms that aren't available to users), the basic idea is that dm
defines and adds a method to a generic function on a given binding.
dm ensures that an appropriate generic is defined on that binding
before adding the method.

for example

  (dm + (x|<int> y|<int> => <int>) ...)

adds a method to the + generic function stored in the + binding. 

you should almost always use dm in your code (in preference to df) as
this allows adding methods in the future.  i will say that i'd like to
move to a purer language where there wasn't such a distinction but
haven't quite worked out all the details.

> I'm not enough of a Goonosticator to say if this means that you do not
> get multi-method dispatch under "dm" or not... Perhaps someone smart
> can comment? 
> 
> ==========================

jonathan