From h.wickham at gmail.com  Fri Feb 26 03:07:50 2010
From: h.wickham at gmail.com (hadley wickham)
Date: Thu, 25 Feb 2010 20:07:50 -0600
Subject: [Rd] proto and baseenv()
In-Reply-To: <20100225194919.00b10700.misc7@emerose.org>
References: <20100225043854.GA26106@klutometis.wikitex.org> 
	<20100224233350.4e3da5db.misc7@emerose.org>
	<4B8666E0.4070808@TU-Dresden.de> 
	<20100225075038.79ca9b63.misc7@emerose.org>
	<4B868B1A.5050409@stats.uwo.ca> 
	<20100225194919.00b10700.misc7@emerose.org>
Message-ID: <f8e6ff051002251807p1047d470s3b439a1d90503eeb@mail.gmail.com>

On Thu, Feb 25, 2010 at 7:49 PM, Ben <misc7 at emerose.org> wrote:
>> I think you are looking for a different object model than proto
>> offers. ?There aren't many languages that offer the prototype object
>> model.
>
> Yes, your probably right---I don't have much experience using the
> prototype model. ?This is the way I expected it to work:
>
>> z <- 1
>> p <- proto(expr={a <- z})
>> p$a
> [1] 1
>> p$z
> Error in get(x, env = this, inherits = inh) : variable "z" was not found

> library(mutatr)
>
> z <- 1
> p <- Object$clone()$do({
+   self$a <- z
+ })
> p$a
[1] 1
> p$z
Error: Field z not found in Object <0x1022b66d8>

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/



[Rd] proto and baseenv()
hadley wickham