From ggrothendieck at gmail.com  Fri Feb 26 04:31:37 2010
From: ggrothendieck at gmail.com (Gabor Grothendieck)
Date: Thu, 25 Feb 2010 22:31:37 -0500
Subject: [Rd] proto and baseenv()
In-Reply-To: <20100226022322.GB19263@klutometis.wikitex.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>
	<20100226022322.GB19263@klutometis.wikitex.org>
Message-ID: <971536df1002251931r4972bcdes9c6910423fc52af6@mail.gmail.com>

On Thu, Feb 25, 2010 at 9:23 PM, Peter Danenberg <pcd at roxygen.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
>
> 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

One would not expect the behavior you cite if you were working in R,
only if you were more familiar with something else.  One can just as
easily argue that consistency and flexibility are more important
principles.   Your preference is inconsistent with how the rest of R
works and is inflexible since everything inherits from Object.  In
contrast proto uses R-like behavior as its default but is flexible
enough that your preference can be accommodated and done so compactly.

Also I think your argument is based partly on repeating the original
erroneous (relative to the writer's intention) proto code without
repeating my correction confusing the discussion with simple user
error.



[Rd] proto and baseenv()
Gabor Grothendieck