From p.dalgaard@biostat.ku.dk  Thu Apr 15 18:00:14 1999
From: p.dalgaard@biostat.ku.dk (Peter Dalgaard BSA)
Date: 15 Apr 1999 19:00:14 +0200
Subject: R's UseMethod() does not dispatch on changed class() (PR#167)
In-Reply-To: Bill Venables's message of "Fri, 16 Apr 1999 01:37:39 +0930 (CST)"
References: <199904151337.PAA00928@biostat.ku.dk> <14102.3787.848394.976662@arcola.stats.adelaide.edu.au>
Message-ID: <x2aew9g6ox.fsf@blueberry.kubism.ku.dk>

Bill Venables <wvenable@arcola.stats.adelaide.edu.au> writes:

> Blundering late into this discussion I'm going to take a chance
> here and venture an opinion on what does happen in S3 UseMethod,
> regardless of what interpretations are made of A.6 in the white
> book.  This is by the "suck it and see" method, the only one I
> trust.  (The chance I take is in supposing this to be useful...)
> 
> 1. At the time of the UseMethod call the principal argument is
>    examined, and evaluated if necessary, and the class it has at
>    that stage is the one used for method dispatch.
> 
> 2. All non-missing arguments are passed on to the method with the
>    values they were supplied with at the time of the original
>    call, not the changed values they may have at the time of
>    dispatch, (including the principal argument).
> 
> 3. Missing arguments that have been given values at the time of
>    method dispatch, as well as local variables, retain their
>    current values when control passes to the method.
> 
> 4. Supplying a second argument to UseMethod() allows some other
>    argument than the first to act as the principal argument.
> 
> 5. Default values for arguments in the method supercede defaults
>    supplied in the generic.
> 
> The method directly occupies the frame of the generic, but
> arguments actually supplied to the generic re-assume their
> original supplied values (even though changes to the principal
> argument prior to method dispatch may determine mathod dispatch.)

Erm, does that cover this case?:

>  f<-function(x){x<-2;print(substitute(x));UseMethod("print")}  
> f(4)
[1] 2
[1] 4
> f((4))
(4)
[1] 2

(It may, I'm just too tired to see it...)

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


R's UseMethod() does not dispatch on changed class() (PR#167)
Peter Dalgaard BSA