Message from discussion
Consider MooTools (was: Re: process.mixin)
Received: by 10.140.83.9 with SMTP id g9mr583497rvb.20.1270316365435;
Sat, 03 Apr 2010 10:39:25 -0700 (PDT)
Received: by 10.140.83.31 with SMTP id g31mr505039rvb.16.1270288248347;
Sat, 03 Apr 2010 02:50:48 -0700 (PDT)
Received: by 10.140.83.31 with SMTP id g31mr505038rvb.16.1270288248305;
Sat, 03 Apr 2010 02:50:48 -0700 (PDT)
Return-Path: <pavel.v.zait...@gmail.com>
Received: from mail-pw0-f53.google.com (mail-pw0-f53.google.com [209.85.160.53])
by gmr-mx.google.com with ESMTP id 25si2169922pzk.4.2010.04.03.02.50.47;
Sat, 03 Apr 2010 02:50:47 -0700 (PDT)
Received-SPF: pass (google.com: domain of pavel.v.zait...@gmail.com designates 209.85.160.53 as permitted sender) client-ip=209.85.160.53;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of pavel.v.zait...@gmail.com designates 209.85.160.53 as permitted sender) smtp.mail=pavel.v.zait...@gmail.com; dkim=pass (test mode) header...@gmail.com
Received: by mail-pw0-f53.google.com with SMTP id 10so1925196pwj.40
for <nodejs@googlegroups.com>; Sat, 03 Apr 2010 02:50:47 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=gamma;
h=domainkey-signature:mime-version:sender:received:in-reply-to
:references:from:date:x-google-sender-auth:received:message-id
:subject:to:content-type;
bh=0b/YqJ4rJ0WV5FMVqGVLZIU1tkjlZh74X/TKtcHIZC8=;
b=A+k470bSx8oHqD20njYUPO2zZhQ9268oAPYsacliZpXKyp/xovoNtoI2kWTUZkg6mn
iUHfGXknwauGbFafzg0OvliAUZEeWSlQnd03VPPEb8P7Up/zPSeQjTiWOfm938+5btPP
EBtYcFdo5q+8qECCcPvek8ngJJWkAq4LRr/pw=
DomainKey-Signature: a=rsa-sha1; c=nofws;
d=gmail.com; s=gamma;
h=mime-version:sender:in-reply-to:references:from:date
:x-google-sender-auth:message-id:subject:to:content-type;
b=nS0XVnWBYdERK+M/X7jHycpyfxcehXJFCnmxejt9kIDDoOOfVkfMzzX9cm9r63VaSV
WABmPkCxmQ0vWMSG60RzgT7bBTHljdedU49w1CSuiekSPWKeD9vE8hw5GWL1ZRzeGRxE
ifQCo1mNjZnWSRvUYKaSSpJcwSvRRxMoiqf3Y=
MIME-Version: 1.0
Sender: pavel.v.zait...@gmail.com
Received: by 10.142.81.10 with HTTP; Sat, 3 Apr 2010 02:50:27 -0700 (PDT)
In-Reply-To: <2e810015-9def-4f10-8401-d1d12aa0a...@q23g2000yqd.googlegroups.com>
References: <aaedcef51003081516wd5a2ccdn54e4c12ee4365...@mail.gmail.com>
<4B9E44FD.9060...@bloggen.dk> <6ea556b21003161606k53e869f3hcbfd9a5d54df0...@mail.gmail.com>
<b0ab5fe6-310e-4f5a-9b51-894317609...@z11g2000yqz.googlegroups.com>
<2e810015-9def-4f10-8401-d1d12aa0a...@q23g2000yqd.googlegroups.com>
From: pavel zaitsev <pa...@md5.ca>
Date: Sat, 3 Apr 2010 05:50:27 -0400
Received: by 10.142.61.35 with SMTP id j35mr1131990wfa.124.1270288247098; Sat,
03 Apr 2010 02:50:47 -0700 (PDT)
Message-ID: <l2i4afdeba91004030250y7a4a9f4di9516210a2b6b5...@mail.gmail.com>
Subject: Re: [nodejs] Re: Consider MooTools (was: Re: process.mixin)
To: nodejs@googlegroups.com
Content-Type: multipart/alternative; boundary=001636e0b620bb0e01048352070b
--001636e0b620bb0e01048352070b
Content-Type: text/plain; charset=ISO-8859-1
Looking at ruby side of things, I think getters and setters should be pushed
into language/stdlib side of things and be dealt with separately. I shrink
from idea of having beans in Javascript.
Just a thought,
Pavel
On Sat, Apr 3, 2010 at 5:42 AM, Marco Rogers <marco.rog...@gmail.com> wrote:
> I finally got around to taking a look at both of the mixin
> replacements suggested by Kris and Rasmus
>
> http://github.com/rsms/oui/blob/master/oui/std-additions.js#L9
> http://github.com/280north/narwhal/blob/master/lib/util.js
>
> Found some things that might be considered issues with both.
>
> Kris, deepUpdate works great except it doesn't check for Getters and
> Setters. Instead it just ends up taking the value returned from any
> Getter properties that are copied. And if the property has only a
> Setter, the property name is created with a value of undefined.
> Examples:
>
> var o = {};
> util.object.deepUpdate(o, {get foo() { return 'foo'; }});
> // o => { foo: 'foo' }
>
> var o = {};
> util.object.deepUpdate(o, {set foo(v) { sys.puts('My new value is ' +
> v); }});
> // o => { foo: undefined }
>
> The version in Rasmus's oui lib handles Getters and Setters, but
> there's a small issue. The function only checks the Setter if the
> Getter is also present.
>
> var o = {};
> mixin(o, {get foo() { return 'foo'; }});
> // o => { foo: [Getter] }
>
> var o = {};
> mixin(o, {get foo() { return 'bar'; }, set foo(v) { sys.puts('My new
> value is ' + v); }});
> { foo: [Getter/Setter] }
>
> var o = {};
> mixin(o, {set foo(v) { sys.puts('My new value is ' + v); }});
> // o => { foo: undefined }
>
> It's completely valid to have a write only property, so it should
> probably copy both either way.
>
> Now I say these MIGHT be issues because the validity of each approach
> can be debated. copying getters/setters is certainly convenient on
> it's face. But it could lead to issues. The getter could be hooked
> into changing some complex internal state of the mixin object. That
> also happens with regular functions though, so maybe that's moot. But
> what about closures? It's probably okay to copy over a function that
> references closure scope variables. But does that make sense for a
> getter? Do getters even pick up closures? I assume so, but it's after
> 5:30am and I don't have the brain power to check :). Anyway, I'm
> curious to hear people's thoughts on this.
>
> One more small difference is that Rasmus's function has a small check
> to prevent circular references (or at least that's how I'm reading
> it).
>
> ...
> else if (target !== d.value) {
> target[k] = d.value
> }
>
> If the value of the mixin property is actually a reference to the
> target object, don't do the mixin. Am I reading that right? Feels
> like a good idea although I don't know how often that would come up.
>
> Thanks for these functions guys. And the rest of the libraries as
> well. They're both really useful, and they dropped into the
> environment and worked no problem. However, Rasmus, I couldn't use
> the npm package manager with yours because you don't provide a
> package.json. Maybe on purpose because you don't expect that stuff to
> be pulled out of oui. Just a heads up though.
>
> :Marco
>
>
> On Mar 16, 8:26 pm, Anders Hellerup Madsen
> <anders.hellerup.mad...@gmail.com> wrote:
> > I use MooTools. The download builder athttp://mootools.net/corecan
> > be used to only pick the parts of the framework that doesn't mess with
> > the DOM, and I think that it's a very cool base library to work from.
> > If you just want aprocess.mixin() replacement, check Core, and
> > uncheck everything else. The functions $mixin() function does
> whatprocess.mixin() used to.
> >
> > String, Array, Number, Function and Hash can also safely be added.
> > They mix in a lot of really nice convenience methods to the prototypes
> > of the basic objects.
> >
> > If you wanted to, could also add Class and Class.Extras from the core-
> > builder, or snatch Date, Date.Extras and the Date.<language> packages
> > for some much needed proper JavaScript date/time support.
> >
> > I'm not sure it would be a good idea to use this in library code, but
> > for applications this is a really neat package.
> >
> > On Mar 17, 12:06 am, Rasmus Andersson <ras...@notion.se> wrote:
> >
> >
> >
> > > I'm using this simple version which covers all my needs:
> http://github.com/rsms/oui/blob/master/oui/std-additions.js#L9
> >
> > > On Mon, Mar 15, 2010 at 15:32, Jannick Knudsen <jann...@bloggen.dk>
> wrote:
> > > > Dear nodejs'ers,
> >
> > > > Has anyone made a solid drop-in replacement forprocess.mixin?
> >
> > > > Or is everybody just doing their own hacks?
> >
> > > > /JJ
> >
> > > > --
> > > > You received this message because you are subscribed to the Google
> Groups
> > > > "nodejs" group.
> > > > To post to this group, send email to nodejs@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > nodejs+unsubscribe@googlegroups.com<nodejs%2Bunsubscribe@googlegroups.com>
> .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/nodejs?hl=en.
> >
> > > --
> > > Rasmus Andersson
>
> --
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com.
> To unsubscribe from this group, send email to
> nodejs+unsubscribe@googlegroups.com<nodejs%2Bunsubscribe@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en.
>
>
--001636e0b620bb0e01048352070b
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Looking at ruby side of things, I think getters and setters should be pushe=
d into language/stdlib side of things and be dealt with separately. I shrin=
k from idea of having beans in Javascript.<br>Just a thought,<br>Pavel<br>
<br><div class=3D"gmail_quote">On Sat, Apr 3, 2010 at 5:42 AM, Marco Rogers=
<span dir=3D"ltr"><<a href=3D"mailto:marco.rog...@gmail.com">marco.roge=
r...@gmail.com</a>></span> wrote:<br><blockquote class=3D"gmail_quote" sty=
le=3D"border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex;=
padding-left: 1ex;">
I finally got around to taking a look at both of the mixin<br>
replacements suggested by Kris and Rasmus<br>
<div class=3D"im"><br>
<a href=3D"http://github.com/rsms/oui/blob/master/oui/std-additions.js#L9" =
target=3D"_blank">http://github.com/rsms/oui/blob/master/oui/std-additions.=
js#L9</a><br>
</div><a href=3D"http://github.com/280north/narwhal/blob/master/lib/util.js=
" target=3D"_blank">http://github.com/280north/narwhal/blob/master/lib/util=
.js</a><br>
<br>
Found some things that might be considered issues with both.<br>
<br>
Kris, deepUpdate works great except it doesn't check for Getters and<br=
>
Setters. =A0Instead it just ends up taking the value returned from any<br>
Getter properties that are copied. =A0And if the property has only a<br>
Setter, the property name is created with a value of undefined.<br>
Examples:<br>
<br>
var o =3D {};<br>
util.object.deepUpdate(o, {get foo() { return 'foo'; }});<br>
// o =3D> { foo: 'foo' }<br>
<br>
var o =3D {};<br>
util.object.deepUpdate(o, {set foo(v) { sys.puts('My new value is '=
+<br>
v); }});<br>
// o =3D> { foo: undefined }<br>
<br>
The version in Rasmus's oui lib handles Getters and Setters, but<br>
there's a small issue. =A0The function only checks the Setter if the<br=
>
Getter is also present.<br>
<br>
var o =3D {};<br>
mixin(o, {get foo() { return 'foo'; }});<br>
// o =3D> { foo: [Getter] }<br>
<br>
var o =3D {};<br>
mixin(o, {get foo() { return 'bar'; }, set foo(v) { sys.puts('M=
y new<br>
value is ' + v); }});<br>
{ foo: [Getter/Setter] }<br>
<br>
var o =3D {};<br>
mixin(o, {set foo(v) { sys.puts('My new value is ' + v); }});<br>
// o =3D> { foo: undefined }<br>
<br>
It's completely valid to have a write only property, so it should<br>
probably copy both either way.<br>
<br>
Now I say these MIGHT be issues because the validity of each approach<br>
can be debated. =A0copying getters/setters is certainly convenient on<br>
it's face. =A0But it could lead to issues. =A0The getter could be hooke=
d<br>
into changing some complex internal state of the mixin object. That<br>
also happens with regular functions though, so maybe that's moot. =A0Bu=
t<br>
what about closures? =A0It's probably okay to copy over a function that=
<br>
references closure scope variables. =A0But does that make sense for a<br>
getter? =A0Do getters even pick up closures? I assume so, but it's afte=
r<br>
5:30am and I don't have the brain power to check :). =A0Anyway, I'm=
<br>
curious to hear people's thoughts on this.<br>
<br>
One more small difference is that Rasmus's function has a small check<b=
r>
to prevent circular references (or at least that's how I'm reading<=
br>
it).<br>
<br>
...<br>
else if (target !=3D=3D d.value) {<br>
=A0 =A0target[k] =3D d.value<br>
}<br>
<br>
If the value of the mixin property is actually a reference to the<br>
target object, don't do the mixin. =A0Am I reading that right? =A0Feels=
<br>
like a good idea although I don't know how often that would come up.<br=
>
<br>
Thanks for these functions guys. =A0And the rest of the libraries as<br>
well. =A0They're both really useful, and they dropped into the<br>
environment and worked no problem. =A0However, Rasmus, I couldn't use<b=
r>
the npm package manager with yours because you don't provide a<br>
package.json. =A0Maybe on purpose because you don't expect that stuff t=
o<br>
be pulled out of oui. =A0Just a heads up though.<br>
<br>
:Marco<br>
<br>
<br>
On Mar 16, 8:26=A0pm, Anders Hellerup Madsen<br>
<div class=3D"im"><<a href=3D"mailto:anders.hellerup.mad...@gmail.com">a=
nders.hellerup.mad...@gmail.com</a>> wrote:<br>
> I use MooTools. The download builder athttp://<a href=3D"http://mootoo=
ls.net/corecan" target=3D"_blank">mootools.net/corecan</a><br>
> be used to only pick the parts of the framework that doesn't mess =
with<br>
> the DOM, and I think that it's a very cool base library to work fr=
om.<br>
</div>> If you just want aprocess.mixin() replacement, check Core, and<b=
r>
> uncheck everything else. The functions $mixin() function does whatproc=
ess.mixin() used to.<br>
<div class=3D"im">><br>
> String, Array, Number, Function and Hash can also safely be added.<br>
> They mix in a lot of really nice convenience methods to the prototypes=
<br>
> of the basic objects.<br>
><br>
> If you wanted to, could also add Class and Class.Extras from the core-=
<br>
> builder, or snatch Date, Date.Extras and the Date.<language> pac=
kages<br>
> for some much needed proper JavaScript date/time support.<br>
><br>
> I'm not sure it would be a good idea to use this in library code, =
but<br>
> for applications this is a really neat package.<br>
><br>
> On Mar 17, 12:06=A0am, Rasmus Andersson <<a href=3D"mailto:ras...@n=
otion.se">ras...@notion.se</a>> wrote:<br>
><br>
><br>
><br>
> > I'm using this simple version which covers all my needs:<a hr=
ef=3D"http://github.com/rsms/oui/blob/master/oui/std-additions.js#L9" targe=
t=3D"_blank">http://github.com/rsms/oui/blob/master/oui/std-additions.js#L9=
</a><br>
><br>
> > On Mon, Mar 15, 2010 at 15:32, Jannick Knudsen <<a href=3D"mai=
lto:jann...@bloggen.dk">jann...@bloggen.dk</a>> wrote:<br>
> > > Dear nodejs'ers,<br>
><br>
</div>> > > Has anyone made a solid drop-in replacement forprocess=
.mixin?<br>
<div><div></div><div class=3D"h5">><br>
> > > Or is everybody just doing their own hacks?<br>
><br>
> > > /JJ<br>
><br>
> > > --<br>
> > > You received this message because you are subscribed to the =
Google Groups<br>
> > > "nodejs" group.<br>
> > > To post to this group, send email to <a href=3D"mailto:nodej=
s@googlegroups.com">nodejs@googlegroups.com</a>.<br>
> > > To unsubscribe from this group, send email to<br>
> > > <a href=3D"mailto:nodejs%2Bunsubscribe@googlegroups.com">nod=
ejs+unsubscribe@googlegroups.com</a>.<br>
> > > For more options, visit this group at<br>
> > ><a href=3D"http://groups.google.com/group/nodejs?hl=3Den" tar=
get=3D"_blank">http://groups.google.com/group/nodejs?hl=3Den</a>.<br>
><br>
> > --<br>
> > Rasmus Andersson<br>
<br>
--<br>
You received this message because you are subscribed to the Google Groups &=
quot;nodejs" group.<br>
To post to this group, send email to <a href=3D"mailto:nodejs@googlegroups.=
com">nodejs@googlegroups.com</a>.<br>
To unsubscribe from this group, send email to <a href=3D"mailto:nodejs%2Bun=
subscribe@googlegroups.com">nodejs+unsubscribe@googlegroups.com</a>.<br>
For more options, visit this group at <a href=3D"http://groups.google.com/g=
roup/nodejs?hl=3Den" target=3D"_blank">http://groups.google.com/group/nodej=
s?hl=3Den</a>.<br>
<br>
</div></div></blockquote></div><br>
--001636e0b620bb0e01048352070b--