From murdoch.duncan at gmail.com  Wed Jun  5 16:28:29 2013
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Wed, 5 Jun 2013 10:28:29 -0400
Subject: [Rd] strange value in .Last.value
In-Reply-To: <87vc5smyiy.fsf@gmail.com>
References: <87wqq94o95.fsf@med.uni-goettingen.de>
	<CAFOpNVF1=rgn6SUD9Cu7LyoFR01d_OoNj5k-two3Bua4XP3rUw@mail.gmail.com>
	<87k3m93t8c.fsf@med.uni-goettingen.de>
	<51AF283A.7080408@gmail.com> <87vc5smyiy.fsf@gmail.com>
Message-ID: <51AF4B0D.8070605@gmail.com>

On 05/06/2013 10:18 AM, Vitalie Spinu wrote:
>
>   >> Duncan Murdoch <murdoch.duncan at gmail.com>
>   >> on Wed, 5 Jun 2013 07:59:54 -0400 wrote:
>
> [...]
>
>   >> As I take it, it is.  Thus, ess/orgmode -- which relies on .Last.value
>   >> for results handling and does not expect that $visible element -- should
>   >> adapt and ignore that explicitly?
>
>   > I think you'll need to ask on the ESS list what the intentions are in this case.
>   > The result of source() is a list with the value and visible entries.  This has
>   > been true "forever", it's not new behaviour.  (It's unfortunate that this is not
>   > clearly documented.)
>
> ESS recently switched to "source" for evaluation in order to preserve
> source references, and that ruins org-babel (a literate programming
> backend) that relies on .Last.value.
>
> Would a
>
>       invisible(source('file.R', echo=TRUE)$value)
>
> be a reliable solution to the problem?

You can count on source()$value to return the last value computed in the 
source() if there was one.  If there were no expressions computed, the 
value will be NULL, but NULL$value is also NULL, so perhaps that is good 
enough for your purposes.

Duncan Murdoch



[Rd] strange value in .Last.value
Duncan Murdoch