Code Monkey home page Code Monkey logo

Comments (1)

mdparker avatar mdparker commented on May 23, 2024

lua_requireref takes a lua_CFunction. That's declared as nothrow. The failure is because luaopen_base is also @nogc.

Wow. This is tricky. As a rule of thumb in all my bindings, I declare function pointer types that are intended to represent function pointers in user code as nothrow, but not @nogc. I don't want to force @nogc on users, but nothrow makes sense for functions being called for C.

In this case, I didn't account for the fact that functions from the Lua C API can be arguments to these parameters. And of course, being from the C API, they are all @nogc.

So the question is what to do. If I make the function pointer type @nogc, then I will almost certainly break user code and will force all functions passed to Lua as a lua_CFunction to be @nogc. I suppose the only real solution to allow pointers to both @nogc functions and non-@nogc functions is to wrap the C function with two overloaded D functions and cast the nothrow @nogc pointer to nothrow before calling the C function.

from bindbc-lua.

Related Issues (9)

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.