-
Notifications
You must be signed in to change notification settings - Fork 127
Conversation
Why are you using symbols everywhere? Doesn't makes it the code more El 4/8/2016 23:16, "facekapow" [email protected] escribió:
|
Well this PR was accidentally submitted, it's now #130, but yeah, I could change the symbols to underscored properties, I just thought that maybe new APIs should use new features, like Promises instead of callbacks or Symbols instead of "private" underscored properties. |
For private attributes I find cleaner to use Object.defineProperty(), or to El 5/8/2016 0:17, "facekapow" [email protected] escribió:
|
Looks like symbols are as fast as regular properties in v8 now, nice! |
Good to know :-) It's just that their lexic seems to be a little bit cumbersome... :-P That's the only objection I have for them :-)
I don't know WeakMap, but code gets as clean as using private attributes and priviledged functions in the constructor without the memory waste. Object.defineProperty() I read it was slower when they were set enumerable=false, that's just what's interesting to use to define "private" attributes and functions... I try to use priviledged functions on the constructor were possible so only it's exposed the public API, and if I need to access to internal structures on subclasses or for testing I use defineProperty to define non-enumerable getters for that info. For me, clean, powerful and easy to use APIs is the top priority. |
Yeah, performance is also important |
Well, either way, trying to have "private" properties in JavaScript is pretty much useless, anyone determined enough could get them. You can get symbols with There is a proposal for ES7 or ES2016 (or whatever it's going to be called) for private properties (which are really more like protected properties in C++ terms), which stores all it's private properties in a private |
El 5/8/2016 14:16, "facekapow" [email protected] escribió:
The point is to not export the WeakMap...
That's what I was asking for, a private WeakMap at the module level. You |
Any thoughts on the API itself? |
@facekapow #130 is the latest code? Going to comment in the PR. |
Adds a `graphics