Announcement

Collapse

New Sub-Forum

In an effort to help make sure there are appropriate categories for topics of discussion that are happening, there is now a sub-forum for databases and database programming under Special Interest groups. Please direct questions, etc., about this topic to that sub-forum moving forward. Thank you.
See more
See less

Simple object autodestruct functionality

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Simple object autodestruct functionality

    "When a variable get's out of scope and if it contains some kind of handle it would be nice if we had a way to destroy the handle automatically"

    See:

    http://www.hellobasic.com/cgi-bin/fo...num=1195328685
    hellobasic

  • #2
    DeleteObject? CloseHandle? [OBJECT] SET/LET objectvar=NOTHING?

    What am I missing here?

    Besides, "Scope" is a 'compile time' attribute/thing only and there is nothing one can do about it at runtime.
    Last edited by Michael Mattias; 26 Nov 2007, 09:44 AM.
    Michael Mattias
    Tal Systems Inc. (retired)
    Racine WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      >What am I missing here?

      Brains?
      hellobasic

      Comment


      • #4
        I'll acknowledge your linked page contains things I don't begin to understand; however, I am totally inured to the concept that the programmer is responsible for cleaning up after himself....

        ...and that the best way to do this is to always "obtain" (create, get, open ) and "release" (close, destroy, free) in the same procedure...making scope moot.
        Michael Mattias
        Tal Systems Inc. (retired)
        Racine WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          This technique could be very handy if you wish to provide a common module (include) to others.
          It can prevent manual cleaning code in your pbmain() for example.

          The functions in that module could also be prepared to verify it's properly intitialized and evt. take action.

          Since the variant will result in a callback call on clearing, you'll be able to take appropriate action.

          I would not use it on severe use like in a windowprocedure, that's to much overhead imo.

          However for neat and clean simple include stuff it's very handy.
          hellobasic

          Comment

          Working...
          X