From pdalgd at gmail.com  Thu Aug 15 08:04:43 2013
From: pdalgd at gmail.com (peter dalgaard)
Date: Thu, 15 Aug 2013 08:04:43 +0200
Subject: [Rd] Inconsistency between eval and withVisible (with patch)
In-Reply-To: <CADwqtCNGqOmfYeOd4bEob7+zu4D=xwiyoAkU9P1KhHnF7FYMJw@mail.gmail.com>
References: <CADwqtCNGqOmfYeOd4bEob7+zu4D=xwiyoAkU9P1KhHnF7FYMJw@mail.gmail.com>
Message-ID: <780A6D7E-AFA3-4C07-AF61-C2ED06580526@gmail.com>


On Aug 15, 2013, at 01:46 , Gabriel Becker wrote:

> R-team,
> 
> The $value element of the return value of *withVisible* does not agree with
> the return value of *eval* when *withVisible* is passed a variable (symbol)
> containing an expression object or anonymous code/expressions which
> generates an expression object when evaluated (such as calls to *parse* or *
> expression*).
> 
> I have attached a patch against the svn trunk which addresses this.
> 
> Example (under devel r63577):
> 
>> withVisible(parse(text="5+pi"))
> $value
> *expression(5+pi)*
> 
> $visible
> [1] TRUE
> 
>> eval(parse(text="5+pi"))
> *[1] 8.141593*
> 

I don't think that is a bug, it is by design. The comparison should be to what happens if you just type the expression at the prompt:

> parse(text="5+pi")
expression(5+pi)


> With the attached patch this is no longer the case:

...so the patch introduces a bug since you can no longer withVisible() something that returns a language object.

> 
>> withVisible(parse(text="5+pi"))
> $value
> *[1] 8.141593*
> 
> $visible
> [1] TRUE
> 
> The patch changes only the withVisible function in eval.c. I'm happy to
> work with / at the direction of an R-core member to get the patch into an
> different form/coding style/fix strategy/etc if its current form is not
> acceptable.
> 
> Thanks,
> ~G
> 
>> sessionInfo()
> R Under development (unstable) (2013-08-14 r63577)
> Platform: x86_64-unknown-linux-gnu (64-bit)
> 
> locale:
> [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
> [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
> [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
> [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
> [9] LC_ADDRESS=C               LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
> 
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
> 
> 
> 
> -- 
> Gabriel Becker
> Graduate Student
> Statistics Department
> University of California, Davis
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



[Rd] Inconsistency between eval and withVisible (with patch)
peter dalgaard