[prev in list] [next in list] [prev in thread] [next in thread] 

List:       r-devel
Subject:    [Rd] capture.output on S4 slot
From:       Dario Strbenac <dstr7320 () uni ! sydney ! edu ! au>
Date:       2014-07-18 4:00:08
Message-ID: 1405659808262.54155 () uni ! sydney ! edu ! au
[Download RAW message or body]

Hello,

capture.output produces a different result if the S4 object was created with a \
constructor than if the body of the constructor is copied and pasted.

setClass("TransformParams", representation(
  transform = "function",
  otherParams = "list")
)

setGeneric("TransformParams", function(transform, ...)
{standardGeneric("TransformParams")})
setMethod("TransformParams", character(0), function()
{
  new("TransformParams", transform = function(){}, otherParams = list())
})

> capture.output(TransformParams()@transform)
[1] "function () "             "{"                       
[3] "}"                        "<environment: 0x363bd60>"
> capture.output(new("TransformParams", transform = function(){}, otherParams = \
> list())@transform)
[1] "function(){}"

Why is the function split into three parts if a constructor is used ?

--------------------------------------
Dario Strbenac
PhD Student
University of Sydney
Camperdown NSW 2050
Australia
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic