Re: [Rd] Attributes of 1st argument in ...

From: Daniel Murphy <chiefmurphy_at_gmail.com>
Date: Sun, 04 Jul 2010 11:11:43 -0700

Thank you, Professor, for drawing my attention to the nifty tracemem function. I'm using the ..1 syntax to check the properties of the S4 class at function call.

The Description at ?"cBind" tells me that I'm not alone in this predicament. Just as Matrix needs its own cBind function, my package will need its own cbindMondate function. Alas, subclasses of mondate will also need their own binding functions, thus defeating one of the purposes of the class paradigm (for binding, anyway).

As an aside, I wonder why, on around line 75, cBind uses 'rep.int("", ncol(r))' rather than the slightly faster 'character(ncol(r))'.

Thanks again,
Dan

On Sun, Jul 4, 2010 at 4:36 AM, Prof Brian Ripley <ripley_at_stats.ox.ac.uk>wrote:

> I think you have missed the use of ..1 etc: see e.g. cBind() in package
> Matrix.
>
> So x <- attr(list(...)[[1L]], "foo") can be x <- attr(..1, "foo")
>
> As for 'extra copying', it all depends on exactly what you are doing, but
> compare
>
> foo1 <- function(...) length(..1)
>> foo2 <- function(...) length(list(...)[[1L]])
>> tracemem(x <- runif(1000))
>>
> [1] "<0x1b27800>"
>
>> foo1(x)
>>
> [1] 1000
>
>> tracemem(x <- runif(1000))
>>
> [1] "<0x1b29800>"
>
>> foo2(x)
>>
> tracemem[0x1b29800 -> 0x10a2200]: foo2
> [1] 1000
>
>
>
> <snip>
> --
> 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
>

        [[alternative HTML version deleted]]



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sun 04 Jul 2010 - 18:13:58 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 05 Jul 2010 - 11:20:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive