Giter Club home page Giter Club logo

Comments (9)

zloirock avatar zloirock commented on August 17, 2024

It seems a duplicate of #48 and #93, but any actions are missed for some years.

from es-abstract.

ljharb avatar ljharb commented on August 17, 2024

It is indeed a duplicate of both; no action will likely be taken for some decades, given that the real problem is the specification - class constructors are not actually callable, they just implement this with a [[Call]] slot that throws a type error. There’s no use case whatsoever for IsCallable returning true here just to throw later (since IsCallable checks basically always guard a Call).

Filing a redundant issue won’t get things moving any more than a comment on the actual issue would, fwiw.

from es-abstract.

zloirock avatar zloirock commented on August 17, 2024

In this case, positioning of es-abstract as a proper set of ECMAScrpt spec abstract operations makes no sense.

from es-abstract.

ljharb avatar ljharb commented on August 17, 2024

This isn't a productive argument. es-abstract is ES AOs for use in polyfills. If you can find a bug in a polyfill caused by IsCallable returning false for a class constructor, I'd be happy to fix it, but if it's just changing when an error is called (because class constructors aren't callable) then it's perfectly reasonable to make choices to deviate from the spec for practicality.

from es-abstract.

zloirock avatar zloirock commented on August 17, 2024

This isn't a productive argument.

This is a productive argument. Even typeof something === 'function' is a proper IsCallable check for modern engines. Sure, some old engines have some minor issues (like FF2 callable regexes - but they are callable). But es-abstract/2020/iscallable returns false for classes. By the spec, classes should be callable and in too many cases in the spec [[Construct]] checked only when [[Call]] existent - so classes will not pass this check when they should., so this helper should never be used as an equal of abstract ES IsCallable operation in polyfills.

from es-abstract.

zloirock avatar zloirock commented on August 17, 2024

The behavior of classes:

function C() {
  if (!new.target) throw TypeError();
}

But it does not remove this [[Call]] from this function.

from es-abstract.

ljharb avatar ljharb commented on August 17, 2024

Yes, I'm aware - and your C function there is effectively not callable, so it's most useful if an "is callable" check returns false for it. In that case, of course, it's not practically possible to do so, but that doesn't mean there's no value in doing so for classes.

from es-abstract.

zloirock avatar zloirock commented on August 17, 2024

IsCallable should check is this function callable by the spec, not effectively - otherwise, it's not an ECMAScript abstract operation.

from es-abstract.

ljharb avatar ljharb commented on August 17, 2024

Thanks, your opinion is noted, and the issue is already tracked in #48.

from es-abstract.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.