From dstr7320 at uni.sydney.edu.au  Fri Jul 18 06:00:08 2014
From: dstr7320 at uni.sydney.edu.au (Dario Strbenac)
Date: Fri, 18 Jul 2014 04:00:08 +0000
Subject: [Rd] capture.output on S4 slot
Message-ID: <1405659808262.54155@uni.sydney.edu.au>

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


[Rd] capture.output on S4 slot
Dario Strbenac