From tlumley@u.washington.edu  Tue May 29 03:05:16 2001
From: tlumley@u.washington.edu (Thomas Lumley)
Date: Mon, 28 May 2001 19:05:16 -0700 (PDT)
Subject: [Rd] argument names in generic print functions (PR#955)
In-Reply-To: <200105282349.BAA14358@pubhealth.ku.dk>
Message-ID: <Pine.A41.4.33.0105281851480.158266-100000@homer03.u.washington.edu>

On Tue, 29 May 2001 Richard.Beare@cmis.csiro.au wrote:

> Hello,
>
> I think this is a bug, although it is possible that I'm doind something
> silly.
>
> I want to be able to determine the argument name for variables passed to
> a generic print function
<snip>

> Under R-1.2.[2,3]
>
> > print(d)
> param name is  d
>
> > d
> param name is  structure(1, class = "foo")
>
> Under Splus 3.4 the responses are
>
> > d<-structure(1, class="foo")
> > d
> param name is  d
> > print(d)
> param name is  d
>
> If I'm going about this the wrong way then please let me know.

I don't think there is a right way to do this in R.  The
read-evaluate-print loop in R prints the *value* of an expression that it
evaluates, not the expression itself. This means that your print()
function doesn't have any way of knowing what the expression was
originally called.  You have to use print() explicitly to get the
parameter name the way you want.

It's not a bug, though it seems to be an incompatibility.

	-thomas

Thomas Lumley			Asst. Professor, Biostatistics
tlumley@u.washington.edu	University of Washington, Seattle

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] argument names in generic print functions (PR#955)
Thomas Lumley