Closed
Bug 721555
Opened 14 years ago
Closed 2 years ago
Provide read-only built-in for accessing native constructors
Categories
(Core :: JavaScript Engine, enhancement)
Core
JavaScript Engine
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: WeirdAl, Unassigned)
Details
Lately, there have been a lot of new top-level functions added. Most of these have names which are not likely to generate collisions (Int32Array, for example). However, recently a Map and a Set top-level constructor were also added.
As a library developer, I would like to ensure I get the native Map function, and not one which a webpage developer writes. It's easy for a webpage developer to write:
function Map() {
// do something
}
and replace the built-in in that scope.
Of course, technically that's his fault, but it's still interfering with my library's function.
Would it be practical to provide a read-only global (BuiltIn) which has these constructors as read-only properties? I could then call new BuiltIn.Map(), and be assured it's the right thing.
Comment 1•14 years ago
|
||
Have you checked out Harmony Modules?
http://wiki.ecmascript.org/doku.php?id=harmony:modules
and bug 568953
Modules have static scoping, so your names would not be polluted by anything else. It's part of ES6 and coming to Firefox this year.
Description
•