Default values for specified properties

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Default values for specified properties

T.J. Crowder-2
Fairly basic specification comprehension question: Is it correct that the `message` property of `Error.prototype` is specified as non-enumerable, because [its definition][1] doesn't explicitly say otherwise and so the default properties listed in Table 4 of [Property Attributes][2] apply?

-- T.J. Crowder


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Default values for specified properties

Allen Wirfs-Brock
"Every other data property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified."
On Apr 20, 2017, at 9:40 PM, "T.J. Crowder" <[hidden email]> wrote:
Fairly basic specification comprehension question: Is it correct that the `message` property of `Error.prototype` is specified as non-enumerable, because [its definition][1] doesn't explicitly say otherwise and so the default properties listed in Table 4 of [Property Attributes][2] apply?

-- T.J. Crowder



es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Default values for specified properties

T.J. Crowder-2
Brilliant, thanks Allen!

-- T.J. Crowder


On Fri, Apr 21, 2017 at 5:52 AM, Allen Wirfs-Brock <[hidden email]> wrote:
"Every other data property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified."
On Apr 20, 2017, at 9:40 PM, "T.J. Crowder" <[hidden email]> wrote:
Fairly basic specification comprehension question: Is it correct that the `message` property of `Error.prototype` is specified as non-enumerable, because [its definition][1] doesn't explicitly say otherwise and so the default properties listed in Table 4 of [Property Attributes][2] apply?

-- T.J. Crowder



es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Default values for specified properties

Michael J. Ryan
In reply to this post by T.J. Crowder-2
I've always felt that made cloning and serializing Error based instances particularly fun.

--
Michael J. Ryan - [hidden email] - http://tracker1.info

Please excuse grammar errors and typos, as this message was sent from my phone.

On Apr 20, 2017 9:40 PM, "T.J. Crowder" <[hidden email]> wrote:
Fairly basic specification comprehension question: Is it correct that the `message` property of `Error.prototype` is specified as non-enumerable, because [its definition][1] doesn't explicitly say otherwise and so the default properties listed in Table 4 of [Property Attributes][2] apply?

-- T.J. Crowder


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Default values for specified properties

T.J. Crowder-2
On Fri, Apr 21, 2017 at 12:11 PM, Michael J. Ryan <[hidden email]> wrote:
I've always felt that made cloning and serializing Error based instances particularly fun.

Well, the one on `Error.prototype` is just the `""` default anyway. But yes, the fact that [`Error`][1] makes the `message` "own" property it creates non-enumerable is slightly surprising. I'm guessing there's history there. :-)

-- T.J. Crowder


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Default values for specified properties

Michael J. Ryan
I always assumed it was an implementation detail historically... stack is also not enumerated, though message is more surprising... I tend to remember for logging/server purposes in particular, and call it out in my clone library, as I've been hit by it many times.

--
Michael J. Ryan - [hidden email] - http://tracker1.info

Please excuse grammar errors and typos, as this message was sent from my phone.

On Apr 21, 2017 4:21 AM, "T.J. Crowder" <[hidden email]> wrote:
On Fri, Apr 21, 2017 at 12:11 PM, Michael J. Ryan <[hidden email]> wrote:
I've always felt that made cloning and serializing Error based instances particularly fun.

Well, the one on `Error.prototype` is just the `""` default anyway. But yes, the fact that [`Error`][1] makes the `message` "own" property it creates non-enumerable is slightly surprising. I'm guessing there's history there. :-)

-- T.J. Crowder


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Default values for specified properties

Allen Wirfs-Brock

On Apr 21, 2017, at 4:42 AM, Michael J. Ryan <[hidden email]> wrote:

I always assumed it was an implementation detail historically... stack is also not enumerated, though message is more surprising... I tend to remember for logging/server purposes in particular, and call it out in my clone library, as I've been hit by it many times.


ES1 (1997) Clause 15:

"Every other property described in this section has the attribute { DontEnum } (and no others) unless otherwise specified." 

Error.prototype and its properties were added to clause 15 in ES3.

Allen 

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Loading...