[Rd] proto and baseenv()

hadley wickham h.wickham at gmail.com
Fri Feb 26 03:07:50 CET 2010


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/



More information about the R-devel mailing list