Brendan Eich (2013-07-28T21:24:13.000Z)
domenic at domenicdenicola.com (2013-08-12T05:17:20.606Z)
Brendan Eich wrote: > Function.setTypeOf(V, U) > > ``` > 1. Let S = ToString(U) > 2. Let T = V > 3. If T is null then > 3a. If S is not "null" and S is not "object", throw > 4. Else > 4a. If T is not a value object constructor, throw > 4b. T = T.prototype > 4c. If TypeofToExemplarMap.has(S), throw > 5. Call TypeofToExemplarMap.set(S, T) > 6. Call ExemplarToTypeofMap.set(T, S) > ``` Correction, see new 4b below: ``` 1. Let S = ToString(U) 2. Let T = V 3. If T is null then 3a. If S is not "null" and S is not "object", throw 4. Else 4a. If T is not a value object constructor, throw 4b. If T and Function are not same-realm, throw 4c. T = T.prototype 4d. If TypeofToExemplarMap.has(S), throw 5. Call TypeofToExemplarMap.set(S, T) 6. Call ExemplarToTypeofMap.set(T, S) ``` I did not add an exception when the current evaluation context's realm is not the same as Function's -- that seems too restrictive, forbidding script in the main window from fixing up typeof for same-origin code that it loads into an iframe. Again, comments welcome (cc'ing Allen since he is realm-master; ES1-5 left realm implicit and singular, contrary to reality in browsers).