Re: [Rd] Capturing environment associated with a promise

2012-10-09 Thread Hadley Wickham
> Both of these are possible in C. See:
>
> https://stat.ethz.ch/pipermail/r-devel/2007-September/046943.html

Cool, thanks.

> It shows how to query an object to see if its a promise and but rather
> than extract the environment it shows how to copy a promise without
> evaluating it; however, it was also my experience that these two were
> what was actually needed rather than being able to extract the
> environment.
>
> I would also recommend you do some testing since I found that adding
> promises did not always make as big a difference in performance as I
> had hoped and the added complexity may not be worth it in all cases.
> For example, I had a version of proto that supported promises but
> ggplot2 only ran slightly faster with it so I did not pursue it any
> further.  On the other hand if you are doing it to support
> self-referential structures then that is a different matter.

I'm mainly interested in this for pedagogy - giving students some
tools to inspect promises without evaluating them would be useful.

Hadley

-- 
RStudio / Rice University
http://had.co.nz/

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Capturing environment associated with a promise

2012-10-09 Thread Hadley Wickham
> Promises are an implementation detail -- we need to be able to change
> them, optimize them away, etc, so there is a limit on what we want to
> expose.  Allowing a query of whether a binding is delayed or not
> should be OK but would want to think that through more carefully
> before committing to this.

Ok, thanks.

Hadley


-- 
RStudio / Rice University
http://had.co.nz/

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Capturing environment associated with a promise

2012-10-08 Thread Gabor Grothendieck
On Mon, Oct 8, 2012 at 9:22 AM, Hadley Wickham  wrote:
> Hi all,
>
> It's possible to capture the expression associated with a promise
> (using substitute). Is there any way to capture the environment
> associated with a promise?  Similarly, is there any way to tell if
> something is a promise without accidentally evaluating it?
>

Both of these are possible in C. See:

https://stat.ethz.ch/pipermail/r-devel/2007-September/046943.html

It shows how to query an object to see if its a promise and but rather
than extract the environment it shows how to copy a promise without
evaluating it; however, it was also my experience that these two were
what was actually needed rather than being able to extract the
environment.

I would also recommend you do some testing since I found that adding
promises did not always make as big a difference in performance as I
had hoped and the added complexity may not be worth it in all cases.
For example, I had a version of proto that supported promises but
ggplot2 only ran slightly faster with it so I did not pursue it any
further.  On the other hand if you are doing it to support
self-referential structures then that is a different matter.

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Capturing environment associated with a promise

2012-10-08 Thread luke-tierney

Promises are an implementation detail -- we need to be able to change
them, optimize them away, etc, so there is a limit on what we want to
expose.  Allowing a query of whether a binding is delayed or not
should be OK but would want to think that through more carefully
before committing to this.

luke

On Mon, 8 Oct 2012, Hadley Wickham wrote:


Hi all,

It's possible to capture the expression associated with a promise
(using substitute). Is there any way to capture the environment
associated with a promise?  Similarly, is there any way to tell if
something is a promise without accidentally evaluating it?

Thanks!

Hadley




--
Luke Tierney
Chair, Statistics and Actuarial Science
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa  Phone: 319-335-3386
Department of Statistics andFax:   319-335-3017
   Actuarial Science
241 Schaeffer Hall  email:   luke-tier...@uiowa.edu
Iowa City, IA 52242 WWW:  http://www.stat.uiowa.edu

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Capturing environment associated with a promise

2012-10-08 Thread Duncan Murdoch

On 12-10-08 9:22 AM, Hadley Wickham wrote:

Hi all,

It's possible to capture the expression associated with a promise
(using substitute). Is there any way to capture the environment
associated with a promise?  Similarly, is there any way to tell if
something is a promise without accidentally evaluating it?



Neither of those is possible in user-level code.  The special functions 
get to see their arguments unevaluated, but users can't write specials, 
and there is no special to extract an environment from a promise.


I think the reasoning is that it keeps the semantics simpler, but I 
can't remember the cases that make user-level promise handling problematic.


Duncan Murdoch

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Capturing environment associated with a promise

2012-10-08 Thread Hadley Wickham
Hi all,

It's possible to capture the expression associated with a promise
(using substitute). Is there any way to capture the environment
associated with a promise?  Similarly, is there any way to tell if
something is a promise without accidentally evaluating it?

Thanks!

Hadley

-- 
RStudio / Rice University
http://had.co.nz/

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel