Sklyar, Oleg (MI London)
2008-Apr-22 09:45 UTC
[Rd] S3 method despatch (changed between 2.6.2 and 2.7.0 RC?)
Dear developers: I have observed a change in the behaviour of S3 method despatch (as I guess related to namespaces) between 2.6.2 and yesterday's 2.7.0 RC and would be grateful if you could comment on that: the 'Axis' function in the 'graphics' namespace calls UseMethod("Axis",x), internally to despatch on the S3 Axis method depending on the type of the argument. Both 2.6.2 and 2.7.0 define the following Axis.* methods in 'graphics': Axis.Date, Axis.POSIXct Axis.POSIXlt and Axis.default. Now, if one defines an Axis.MyClass outside of the 'graphics' namespace, it is called automatically by 2.6.2 on objects of MyClass, i.e. R would search for further method definition outside of the graphics namespace. Looks like this behaviour has changed in 2.7.0 so that UseMethod called in a given namesspace (graphics) does not despatch on methods defined in another namespace (global or another package) as the example below shows. Have I done something wrong? Is it an intended behaviour, any idea how to go around it? Thanks, Oleg PS: The difference in the code below is that 2.6.2 calls Axis.MyClass in plot.default (and thus prints the message), while 2.7.0 does not. x = 1:5 class(x) = c("MyClass",class(x)) Axis.MyClass = function (x, at, ..., side, labels=TRUE) { print("running Axis.MyClass") axis(side, at=if(!missing(x)) x else at, labels=labels, ...) } methods("Axis") plot(x, 1:5) == >>> Output from 2.6.2 RC (2008-02-08) ======================================> methods("Axis") [1] Axis.Date* Axis.MyClass Axis.POSIXct* Axis.POSIXlt* Axis.default* Non-visible functions are asterisked> plot(x, 1:5)[1] "running Axis.MyClass"> > sessionInfo()R version 2.6.2 (2008-02-08) x86_64-unknown-linux-gnu locale: LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=C;LC_MO NETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-8;LC_NAMEC;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_IDENTIFICATI ON=C attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] rcompgen_0.1-17 tools_2.6.2 == >>> Output from 2.7.0 RC (2008-04-20 r45403) ===============================> methods("Axis") [1] Axis.Date* Axis.MyClass Axis.POSIXct* Axis.POSIXlt* Axis.default* Non-visible functions are asterisked> plot(x, 1:5) > > sessionInfo()R version 2.7.0 RC (2008-04-20 r45403) x86_64-unknown-linux-gnu locale: LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=C;LC_MO NETARY=C;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-8;LC_NAME=C;LC_ADDRE SS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] tools_2.7.0 Dr Oleg Sklyar Technology Group Man Investments Ltd +44 (0)20 7144 3803 osklyar at maninvestments.com ********************************************************************** The contents of this email are for the named addressee(s) only. It contains information which may be confidential and privileged. If you are not the intended recipient, please notify the sender immediately, destroy this email and any attachments and do not otherwise disclose or use them. Email transmission is not a secure method of communication and Man Investments cannot accept responsibility for the completeness or accuracy of this email or any attachments. Whilst Man Investments makes every effort to keep its network free from viruses, it does not accept responsibility for any computer virus which might be transferred by way of this email or any attachments. This email does not constitute a request, offer, recommendation or solicitation of any kind to buy, subscribe, sell or redeem any investment instruments or to perform other such transactions of any kind. Man Investments reserves the right to monitor, record and retain all electronic communications through its network to ensure the integrity of its systems, for record keeping and regulatory purposes. Visit us at: www.maninvestments.com
Maybe Matching Threads
- graphics::Axis loosing S3/S4 class attributes of 'x' in 2.7.0 RC
- as.POSIXct/as.POSIXlt generics
- ISOdate/ISOdatetime performance suggestions, other date/time questions
- setClassUnion with numeric; extending class union
- 'cat' and 'write' as generic, just like 'c', 'cbind' etc?