GithubHelp home page GithubHelp logo

Comments (4)

kovidgoyal avatar kovidgoyal commented on May 31, 2024

You forgot new

from rapydscript-ng.

BruceSherwood avatar BruceSherwood commented on May 31, 2024

Duh. And I confused what's possible within a self-contained program and in an external library. As your README says about new, "This is very useful for avoiding a common JavaScript error of creating 'undefined' objects by forgetting this keyword."

MIght it be useful to have a compile flag, say "--library", so that a Python class would be compiled to something like this?

function PhysAxis(obj, numLabels, args) {
    if (!(this instanceof PhysAxis)) return new PhysAxis(obj, numLabels, args)

Or more generally, why not always compile classes this way, and eliminate inserting "new" into calls to them? Then the transpiled program would work either as a main program or a library, wouldn't it?

from rapydscript-ng.

kovidgoyal avatar kovidgoyal commented on May 31, 2024

Not worth it, IMO. Every extra output option, slows down compilation, because the result of running with it has to be cached, to enable incremental compilation. Also, it means that the function cannot be used as a generic anymore, which is common in at least some parts of the JS ecosystem, and I think it will break at least some types of multiple inheritance.

from rapydscript-ng.

BruceSherwood avatar BruceSherwood commented on May 31, 2024

I obviously don't know all the ramifications, but if it were an optional flag?

from rapydscript-ng.

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.