Dear ES discuss subscribers,
I'm Kenta Moriuchi,
Department of Art and Information Design
Kyushu University in Japan
I propose `Protected State`.
In ES2015:
```js
// utility
function createProtectedStorage() {
const wm = new WeakMap();
return (self, protectedClass) => {
const
> Le 19 janv. 2016 à 08:55, Simon Pieters a écrit :
>
> On Fri, 15 Jan 2016 16:49:13 +0100, Andrea Giammarchi
> wrote:
>
>> FWIF `RegExp.$1` and others are de-facto standard and removing them would
>> break the Web and much more.
>
> Indeed.
Could this be achieved with decorators?
> On 19 Jan 2016, at 8:31 PM, 森建 wrote:
>
> Dear ES discuss subscribers,
>
> I'm Kenta Moriuchi,
> Department of Art and Information Design
> Kyushu University in Japan
>
> I propose `Protected State`.
>
> In ES2015:
>
> ```js
>
@Kenta: Is your model likely to break/leak private data into foreign contexts
once you start binding `this`?
On the other hand: Should you ever need to bind `this` for class functions?
Right now, I'm not entirely sure whether the implementation of "protected" can
be runtime-safe.
About your
It could be achieved with decorators but it won't be the same.
On a side note, that `Object.assign` operation doesn't do what you think it
does, there are better patterns (boilerplates, actually ...) to copy own
properties over within their descriptors, if different from enumerable data
IIRC the difference between protected and private is that a private field
works within the class but not subclasses while protected means from a
subclass you can use directly `protected.whatever` even if `whatever` is
not defined but it's inherited from the super class.
Private is private, and
I'm not sure if this is well-known; it was certainly surprising to me.
Consider the following program:
`let func = () => 0;
(function(){
{
function func() {
return 1;
}
}
return func();
})();`
The return value of the second function depends on whether this program is
On Tue, Jan 19, 2016 at 9:54 AM, Kevin Gibbons
wrote:
> I'm not sure if this is well-known; it was certainly surprising to me.
>
> Consider the following program:
> `let func = () => 0;
>
> (function(){
> {
> function func() {
> return 1;
> }
> }
>
FWIW I think that's expected. Strict mode would throw otherwise but of
course if you have an outer scope reference to whatever you are invoking
that's indeed what you invoke.
Making it behave similarly in both strict and non strict would be a mistake
for the existing sloppy code but I agree that
It would be helpful to link to gists or github repos rather than pasting
code inline.
You may also be interested to read this proposal:
https://github.com/wycats/javascript-private-state
On Tue, Jan 19, 2016 at 8:43 AM, 森建 wrote:
> @Andrea Giammarchi
>
> Thank you for
Hi Mark,
Sorry for the delay, thank you for that response it was very useful.
Do you think it would make sense to open an API for Error stack that would
be purely based upon user agent implementation? I'm not familiar with the
internals of the traces but I have seen comments mentioning
to be clear: no, Object.assign does not copy accessors in a meaningful way,
it copies the result of the getter, not its descriptor.
That page at MDN has also many errors, including the function myAssign that
copies keys but not Symbols.
Gonna fix that, best regards
On Tue, Jan 19, 2016 at 1:16
@Thomas
>Could this be achieved with decorators?
I want to get Syntax Sugar.
But I didn't have an idea using decorators, thank you!
@kdex
>About your nomenclature: Why name it `protected` rather than `private`?
Am I missing a key difference between the two here?
This is not `private`
Sorry, I misunderstood descriptor and accessor. I try it!!
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
I make it!
```js
"use strict";
// utility
function createProtectedStorage() {
const wm = new WeakMap();
return (self, protectedClass) => {
const map = wm.get(self);
if(protectedClass == null) {
if(map) {
return map;
} else {
const ret =
Sorry, I must use `Object.getOwnPropertySymbols`.
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
`for(let key of [ ...Object.getOwnPropertyNames(map),
...Object.getOwnPropertySymbols(map) ])`
... or ...
`for(let key of Reflect.ownKeys(map))`
On Tue, Jan 19, 2016 at 4:10 PM, 森建 wrote:
> maybe okay.
>
> ```js
> "use strict";
>
> // utility
> function
maybe okay.
```js
"use strict";
// utility
function createProtectedStorage() {
const wm = new WeakMap();
return (self, protectedClass) => {
const map = wm.get(self);
if(protectedClass == null) {
if(map) {
return map;
} else {
const ret =
@Andrea Giammarchi
Thank you for supporting my code, I got JavaScript knowledge a lot!
@Subscribers
If there is not any problems, would you kindly discuss about this syntax sugar?
___
es-discuss mailing list
es-discuss@mozilla.org
19 matches
Mail list logo