archives

« Bugzilla Issues Index

#528 — 8.12.8: refactor away repetition


In 8.12.8 "[[DefaultValue]] (hint)",
there's a lot of repetition, which obscures what's going on.

I suggest refactoring the two algorithms (and the subsequent paragraph)
down to this:

When the [[DefaultValue]] internal method of /O/ is called with optional /hint/,
the following steps are taken:

1. If /hint/ is String or if /hint/ is not supplied and /O/ is a Date object,
Let propertyNamesToTry be the list ("toString", "valueOf").
2. Else
Let propertyNamesToTry be the list ("valueOf", "toString").

3. For each /propertyName/ in /propertyNamesToTry/ in order, do:
a. Let /propertyValue/ be the result of calling the [[Get]]
internal method of object /O/ with argument /propertyName/.
b. ReturnIfAbrupt(/propertyValue/).
c. If IsCallable(/propertyValue/) is true then,
i. Let /callResult/ be the result of calling the
[[Call]] internal method of /propertyValue/,
with /O/ as the this value and an empty argument list.
ii. ReturnIfAbrupt(/callResult/).
iii. If /callResult/ is a primitive value, return /callResult/.

4. Throw a TypeError exception.


fixed in rev20 editor's draft

7.1.1


fixed in rev20 draft, Oct. 28, 2013