On Jul 10, 2011, at 9:59 AM, Dmitry A. Soshnikov wrote: > On 10.07.2011 20:36, Brendan Eich wrote: >> So the goal of Array.of is to provide a constructor that, unlike Array, does >> not have that insane special case for Array(42), which presets length (and >> hints to implementations to preallocate) but leaves holes in [0, length). > > I still don't see how it will help in manual enumeration of the same items > which may be directly passed to brackets of array initialiser. We enumerate > (by hands) items here, right? -- Array.of(1, 2, 3). And we enumerate items > here (by hands also) -- [1, 2, 3]. The difference is that the second case > syntactically more elegant and sugared and also doesn't require non-needed > function activation with allocating call-stack frame, etc.
That's all true, but beside the point. The use-case is when you can't write a literal, because you are passing a function-that-constructs as a funarg, and the eventual caller may pass only one number arg, or several args. In that case, Array will not do the right thing in the one-number-arg case. That's the reason for Array.of. /be _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

