Coder Social home page Coder Social logo

Function bind about function-references HOT 6 CLOSED

webassembly avatar webassembly commented on May 31, 2024
Function bind

from function-references.

Comments (6)

rossberg avatar rossberg commented on May 31, 2024

Are you referring to the bullet that defines the type of the instruction? Sorry, there actually was a typo there, the immediate should have been $t', the resulting function type. With that fixed, the instruction takes a ref to a function of type $t and its first n arguments and returns another reference to a function of type $t' with the respectively shortened parameter type list.

There is no restriction on the life time of the closure.

from function-references.

fgmccabe avatar fgmccabe commented on May 31, 2024

from function-references.

rossberg avatar rossberg commented on May 31, 2024

The motivation here was that functions in Wasm are closures already (over their module instance). And since all current production engines allow dynamic module instantiation they already have to deal with the same life time issues for the resulting closures. This may be via a GC or via reference counting. In a way, func.bind would just piggyback on the existing mechanism (which hopefully is efficient enough for this use case).

from function-references.

fgmccabe avatar fgmccabe commented on May 31, 2024

That 'closing over the machine' that is currently done would tie the lifetime of a closure to the lifetime of the instance. What is needed is to be able to relate the lifetime of a closure to other elements within an instance -- i.e., GC of closures.

from function-references.

rossberg avatar rossberg commented on May 31, 2024

The life times of a module instance and that of one of its functions are not necessarily the same, even now, although one typically keeps the other alive (which theoretically can happen either direction). At least in principle, individual functions can already be dead while their module is still in use.

In general, we'll have a number of objects in Wasm that require dynamic life time management by the engine. Exception packages are another such example.

I didn't understand what you mean by closing over the "machine".

from function-references.

rossberg avatar rossberg commented on May 31, 2024

Func.bind never had consensus and has been dropped from the proposal.

from function-references.

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.