T.J. Crowder (2017-07-05T20:23:52.000Z)
On Wed, Jul 5, 2017 at 7:10 PM, Boris Cherny <boris at performancejs.com>
wrote:
> The use case is similar to Scala’s block scoped implicits. In my
> application code I want Array.prototype.indexOf to return an
> Option<number>, rather than number | -1.

Why does it have to be called `indexOf`? Why not `fooIndexOf`, where `foo`
is a short app-specific prefix? Changing the meaning of `indexOf` seems
like changing black to white and running the risk of getting killed at the
next zebra crossing.

On Wed, Jul 5, 2017 at 7:42 PM, Boris Cherny <boris at performancejs.com>
wrote:
> I tried that approach, but it doesn’t work when creating objects
> via literal notation ([], {}). A bit clumsy to have to write
> “new Array(1,2,3)", or “Array(1,2,3)” every time.

Surely not too bad if you provide yourself a short array-creation wrapper,
like `a`?

-- T.J. Crowder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170705/6906b02e/attachment.html>
tj.crowder at farsightsoftware.com (2017-07-05T20:26:59.807Z)
On Wed, Jul 5, 2017 at 7:10 PM, Boris Cherny <boris at performancejs.com> wrote:

> The use case is similar to Scala’s block scoped implicits. In my
> application code I want Array.prototype.indexOf to return an
> Option<number>, rather than number | -1.

Why does it have to be called `indexOf`? Why not `fooIndexOf`, where `foo`
is a short app-specific prefix? Changing the meaning of `indexOf` seems
like changing black to white and running the risk of getting killed at the
next zebra crossing.

On Wed, Jul 5, 2017 at 7:42 PM, Boris Cherny <boris at performancejs.com> wrote:

> I tried that approach, but it doesn’t work when creating objects
> via literal notation ([], {}). A bit clumsy to have to write
> “new Array(1,2,3)", or “Array(1,2,3)” every time.

Surely not too bad if you provide yourself a short array-creation wrapper,
like `a`?

-- T.J. Crowder