archives

« Bugzilla Issues Index

#1098 — ToPrimitive's PreferredType parameter


The nature of ToPrimitive's PreferredType parameter is odd. It's described as "an optional hint", and its values are denoted (in the ToPrimitive algorithm, and in invocations of it) as "hint Number" and "hint String".

You could eliminate this ad-hoc-ness by using the same convention as @@ToPrimitive and OrdinaryToPrimitive. I.e., change:
hint Number to "number"
and
hint String to "string"

(If you also renamed 'PreferredType' as 'hint', you could delete steps 2 and 3 of the ToPrimitive algorithm.)


I have mixed feelings about this approach. Just using strings would simplify things. However, the hint is strictly a specification artifact (at this level). It seems like good hygiene to avoid using ECMAScript language values as such specification meta values.

I realize the historically the spec. has been very inconsistent in the application of this "rule" and I suspect we will never get away from using true, false, and maybe undefined as both language and spec meta values.

So, I'm still not really sure which way to go on this.