From pcd at roxygen.org  Fri Feb 26 03:23:22 2010
From: pcd at roxygen.org (Peter Danenberg)
Date: Thu, 25 Feb 2010 20:23:22 -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: <20100226022322.GB19263@klutometis.wikitex.org>

> > 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

Which is exactly how it should work! Namespace pollution is orthogonal
to the specific object model, and Duncan's assertion about the
prevalence of prototypes is a red herring.

Here's how it works in Scheme, for instance, using Neil van Dyke's
Prototype-Delegation package:[1]

  #;1> (use protobj)
  #;2> (define z 1)
  #;3> (define a (%))
  #;4> (! a a z)
  #;5> (? a a)
  1
  #;6> (? a z)

  Error: Object has no such slot:
  #<object>
  z

Just like one would expect! And since protobj is based on self,
Ungar-Smith's original prototype system,[2] I suspect that self
behaves similarly.

Footnotes: 
[1]  http://www.neilvandyke.org/protobj/

[2]  http://research.sun.com/self/papers/self-power.html



[Rd] proto and baseenv()
Peter Danenberg