GithubHelp home page GithubHelp logo

Handle struct values (non-pointer) about qml HOT 6 OPEN

go-qml avatar go-qml commented on August 24, 2024
Handle struct values (non-pointer)

from qml.

Comments (6)

niemeyer avatar niemeyer commented on August 24, 2024

If I understand what you're trying to achieve, this won't work, for the same reason this does not work:

http://play.golang.org/p/jMTwpE5bNo

Does that make sense?

If so, I'll change the topic of this issue as that error message is really bad and should be fixed.

from qml.

quarnster avatar quarnster commented on August 24, 2024

My point is that this works: http://play.golang.org/p/sbPAvbv6cf

from qml.

niemeyer avatar niemeyer commented on August 24, 2024

The original point was about modifying the returned value, which does not work. But yeah, we can allocate a new value and copy it. Somewhat wasteful, but maybe it's worth to make such methods work.

from qml.

niemeyer avatar niemeyer commented on August 24, 2024

Yeah, let's do that. Thanks for bringing this up.

from qml.

quarnster avatar quarnster commented on August 24, 2024

Making Go-QML "convert" return values into set-able types (if they weren't already) makes the QML script side behave more as the same code would work if it was written in Go, so IMO it's worth it.

There's already unavoidable overhead in every QML/Go function call boundary and any app where this boundary has a noticeable performance impact would do better in trying to get rid of the QML/Go boundary crossing in the first place.

The memory allocation could potentially be partially removed by using reflect.NewAt and keeping a small piece of memory for QML function stack, but I doubt the complexity of that is actually worth the effort :)

IIRC I also saw a panic-call when passing a "non-hashable" struct as a function argument or something when skimming the code. Would it be possible to use a similar approach there?

from qml.

niemeyer avatar niemeyer commented on August 24, 2024

Yeah, the unhashable note is about the same issue. If we copy the value and get an address for it, both problems will go away.

from qml.

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.