Do you mean something like:> sq <- function(x) x^2 > sq(2)[1] 4> sq(9)[1] 81> sq1 <- sq > sq1(9)[1] 81 On Wed, 14 May 2003, G?ran Brostr?m wrote:> Date: Wed, 14 May 2003 09:59:13 +0200 (CEST) > From: G?ran Brostr?m <gb at stat.umu.se> > To: R-help <r-help at stat.math.ethz.ch> > Subject: [R] Two names of a function > > > Is it possible to let a function be known under two names without having > two identical copies of the function body? > > --- > G?ran Brostr?m tel: +46 90 786 5223 > Department of Statistics fax: +46 90 786 6614 > Ume? University http://www.stat.umu.se/egna/gb/ > SE-90187 Ume?, Sweden e-mail: gb at stat.umu.se > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help >-- Cheers, Kevin ------------------------------------------------------------------------------ /* Time is the greatest teacher, unfortunately it kills its students */ -- Ko-Kang Kevin Wang Master of Science (MSc) Student SLC Tutor and Lab Demonstrator Department of Statistics University of Auckland New Zealand Homepage: http://www.stat.auckland.ac.nz/~kwan022 Ph: 373-7599 x88475 (City) x88480 (Tamaki)
Is it possible to let a function be known under two names without having two identical copies of the function body? --- G?ran Brostr?m tel: +46 90 786 5223 Department of Statistics fax: +46 90 786 6614 Ume? University http://www.stat.umu.se/egna/gb/ SE-90187 Ume?, Sweden e-mail: gb at stat.umu.se
On Wed, 14 May 2003, G?ran Brostr?m wrote:> Is it possible to let a function be known under two names without having > two identical copies of the function body?Well, that's what .Alias did (have one copy), and it has been removed. There's nothing to stop you writing a version of .Alias via .Call, except there were good reasons to remove it. Given that, perhaps you should ask what how to do what you really want to do (the top-level task that prompted this question). I don't think you can even know if there are two copies of the function body: there can be potential copies of R objects which are shared until one is altered. I would have to read the internal code very carefully to find out if e.g. body<- made an actual copy. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595