Git Product home page Git Product logo

Comments (2)

GoogleCodeExporter avatar GoogleCodeExporter commented on July 23, 2024
I will consider it but there the problem of how SLB should treat the memory of 
object "f", for example:

{
   Foo f; 
   m->set("Bar", ... , &f);
}

after the block f is no longer a valid pointer...  but this, can lead to memory 
leaks:

{ 
   Foo *f = new Foo();
   m->set("Bar", ... , &f);
}

So, in the end its better to wrap Foo class with SLB and make some sort of 
wrapper around a given object instead. I will consider how to do it, but if you 
have any insight about the management of the memory it would be great to know.

Original comment by [email protected] on 19 Feb 2012 at 1:00

  • Changed state: Accepted

from slb.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 23, 2024
It is a tricky problem. I think the only options are to force the user to make 
sure they don't do silly things like that and hope they manage their memory 
correctly, OR do something like you have mentioned and have a wrapper that SLB 
uses to manage the lifetime of the object. The user then might do something 
like (if they wanted to manually remove the binding and clean the memory being 
used):

m->unset("Bar");

However, this doesn't stop them from doing silly things like this:

{
   Foo *f = new Foo();
   m->set("Bar", ... , &f);
   delete f;
   m->unset("Bar"); // potential crash
}

I don't think this is a major concern though as the user should still be 
responsible for overall management.

In any case, I think adding member function support would be really useful 
feature. I just moved over to SLB from luabind and I'm really liking it. The 
member function ability is the only thing I feel it is lacking at the moment. 
Nice work so far!

Original comment by [email protected] on 19 Feb 2012 at 9:59

from slb.

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.