This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 12445 - Consider making properties corresponding to IDL constants be configurable and unwritable
Summary: Consider making properties corresponding to IDL constants be configurable and...
Status: RESOLVED WONTFIX
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: WebIDL (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Cameron McCormack
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-07 23:59 UTC by Cameron McCormack
Modified: 2011-05-08 23:37 UTC (History)
7 users (show)

See Also:


Attachments

Description Cameron McCormack 2011-04-07 23:59:18 UTC
We should maybe make properties corresponding to IDL constants be configurable, unwritable data properties, for consistency with the configurability of those for operations and attributes.
Comment 1 Brendan Eich 2011-04-08 15:02:22 UTC
This may be the right attribute combination based on what browsers implement as well, but it is not the high-integrity approach. Cc'ing some tc39ers.


/be
Comment 2 Mark S. Miller 2011-04-08 17:23:19 UTC
(In reply to comment #1)
> This may be the right attribute combination based on what browsers implement as
> well, but it is not the high-integrity approach. Cc'ing some tc39ers.

As long as an initialization script can freeze these properties before other code runs, there's no fatal problem here. But this seems weird for a concept labeled "constant", and it makes the obvious optimizations harder to implement.

Since WebIDL does have a distinct notion of "constant", and since the ConstExpr used to initialize the constant http://dev.w3.org/2006/webapi/WebIDL/#prod-ConstExpr is not something that an initialization script might plausibly want to alter, it would seem that the normal reasons for making properties initially configurable do not apply. Why not make declared constants non-writable, non-configurable data properties?

Another precedent to look at is, for example, Math.E, which is a non-writable, non-configurable data property, as are the other Math constants. (And yes, I am aware that these are speced by EcmaScript rather than WebIDL.)



> 
> /be
Comment 3 Cameron McCormack 2011-04-08 18:04:57 UTC
(In reply to comment #2)
> Since WebIDL does have a distinct notion of "constant", and since the ConstExpr
> used to initialize the constant
> http://dev.w3.org/2006/webapi/WebIDL/#prod-ConstExpr is not something that an
> initialization script might plausibly want to alter, it would seem that the
> normal reasons for making properties initially configurable do not apply.

What are the normal reasons, secure JS subsets?  I've been considering the use case of scripts wanting to add hooks into existing DOM APIs, for example as a completely synthetic use case, maybe you want to count how many times a particular property for a constant is looked up.

> Why not make declared constants non-writable, non-configurable data properties?

That's how they're currently defined.

> Another precedent to look at is, for example, Math.E, which is a non-writable,
> non-configurable data property, as are the other Math constants. (And yes, I am
> aware that these are speced by EcmaScript rather than WebIDL.)

That's definitely a reasonable precedent to consider.
Comment 4 Travis Leithead [MSFT] 2011-04-27 06:17:54 UTC
FWIW:

We had a similar discussion in IE when deciding what attributes to give "const" properties. During Beta, we had the properties as configurable, but later changed our minds and made them fully "const" to emphasize the meaning of the term. 

So now, in IE9 RTM, we have:

>> Object.getOwnPropertyDescriptor(Node, "ELEMENT_NODE") 
{
	value : 1,
	writable : false,
	enumerable : true,
	configurable : false
}
Comment 5 Cameron McCormack 2011-05-08 23:09:29 UTC
OK, I will leave them non-configurable.
Comment 6 Jonas Sicking (Not reading bugmail) 2011-05-08 23:37:22 UTC
Adjusting resolution as the decision was to not make a change. (which I'm fine with for what it's worth).