Giter Club home page Giter Club logo

Comments (6)

viniciusjarina avatar viniciusjarina commented on July 22, 2024

You should consider FromIntPtr an "weak reference" do not dispose it.

from keralua.

unconverged avatar unconverged commented on July 22, 2024

In this case the returned object should not be marked as disposable. I mean, if an object is disposable then it should be disposed. Since we call a method that returns a disposable object, we are expected to dispose it properly, that's what IDisposable is made for. And it is not obvious that we should not dispose it in such a case. Leaving dangling disposable objects without properly cleaning the resources is a bad practice, I think.

from keralua.

viniciusjarina avatar viniciusjarina commented on July 22, 2024

an type that is disposable don't me it SHOULD be disposed, it means it CAN be disposed. Is common practice to to have disposed objects being returned in APIs

For instance in Xamarin.iOS https://learn.microsoft.com/en-us/dotnet/api/uikit.uiview.viewwithtag?view=xamarin-ios-sdk-12 ViewWithTag will return an UIView that is Disposable.

The .NET docs say, you should disposed when you finish using it.

from keralua.

noncom avatar noncom commented on July 22, 2024

I beg your pardon here for interjecting, but then why is it IDisposable?

I've been thinking the same as the OP, but I also see your explanation that there's no must in that it must be disposed.

Then my question is:
What are the situations when it can be disposed? What is the intended usage pattern when I might have actually disposed it?

from keralua.

viniciusjarina avatar viniciusjarina commented on July 22, 2024

It's disposable because the Lua object is disposable. For instance Console.Out return a disposable TextWriter but that doesn't mean you MUST dispose it.

from keralua.

noncom avatar noncom commented on July 22, 2024

Ah alright, so in this case we're getting the Lua object directly, not just a reference to it.

Then yeah, I guess we shouldn't dispose it.

To answer my own question, as I understand it: we can dispose it if we really want to dispose the Lua VM at this point.

from keralua.

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.