--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
On Saturday, July 7, 2012 at 10:28 AM, Mariusz Nowak wrote:
This is the use case we were missing, you want to do same thing I've once tried to do in domjs https://github.com/medikoo/domjsCurrently I think there's no better solution than polluting global scope.In domjs I resolved it by introducing dynamic scope ( https://github.com/medikoo/domjs/blob/master/lib/dscope.js ).
WeakMap/Map/Set are available in V8 for quite some time. You just need to run with --harmony.
(Though storing anything in a WeakMap with a string key might lead to a hard to explain memory leaks).
Vyacheslav Egorov
On Sunday, July 8, 2012 at 6:05 AM, Vyacheslav Egorov wrote:
WeakMap/Map/Set are available in V8 for quite some time. You just need to run with --harmony.
Apparently we define 'stable' differently. It is behind the flag because it is from the next non-finalized JS standard, not because it is crashy or buggy.
As for string keys: I thought you are proposing to use weakmap like that here, sorry I misunderstood.
Implementation has no problem with them (so nothing to report) but primitives can be shared in unexpected ways (e.g. two objects with the property foo hold the same instance of string 'foo'.) so one should always keep that in mind, because value will never be released if key is strongly reachable.
Vyacheslav Egorov
On Sunday, July 8, 2012 at 9:15 AM, Vyacheslav Egorov wrote:
Apparently we define 'stable' differently.
It is behind the flag because it is from the next non-finalized JS standard,
not because it is crashy or buggy.
As for string keys: I thought you are proposing to use weakmap like that here, sorry I misunderstood.
Implementation has no problem with them (so nothing to report) but primitives can be shared in unexpected ways (e.g. two objects with the property foo hold the same instance of string 'foo'.)
so one should always keep that in mind, because value will never be released if key is strongly reachable.
I wouldn't call the --harmony flag as a whole stable, primarily because the Proxy implementation hasn't be updated to the new spec. I would be hesitant to call Map and Set stable, because the iterator spec is just getting to the point of implementable now and isn't implemented yet in V8. It's not that what functions they have aren't stable, it's just that they lack some key functionality. WeakMap, however, is perfectly stable and feature complete and I would very much love to see that split off and enabled by default.(also primitives are invalid keys for WeakMaps and throw an error)
I still think we have different definitions of stable :-) I only mean
"should not crash and burn, and if crashes and burns --- please
report". You seem to imply "follows latest draft, is not going to
change" as well. Surely by this definition --harmony is not stable, it
might not be up to date and it will change, just like the draft
itself.
It is highly unlikely (though I can't predict the future) that any
part of --harmony will be moved out from under the flag before final
standard is released.
There was no iterator api specified at harmony:simple_maps_and_sets
> Map and Set are missing their iterator APIs completely,
when V8 implemented them. Erik Arvidsson amended the wiki only a month
ago.
Which AFAIK was perfectly aligned with old opt-in story (aka extended
> let is only allowed with the "use strict" prologue...
mode); opt-in however was dropped in favor of 1JS.
Fair point. I don't think modules were ever declared working and I am
> ES module syntax support appears and disappears (when it is available, module identifiers are assigned as undefined),
not sure why --harmony implies --harmony-modules. Need to ask Andreas
about that (he is working on finishing the implementation afaik).
Yes, they don't. But objects hold strings. obj = {foo:0} holds "foo".
> Strings don't hold any shared references in JavaScript
Fortunately spec foresaw these complications and forbade using
primitives as keys as Brandon points out.