is there a way to delete global variables?

Discussion in 'Cadence' started by bennys, Oct 31, 2005.

  1. bennys

    bennys Guest

    once a variable is defined (for example by a=5)
    is there a way to remove it from the memory without exiting cadence?
    (after which an error "*Error* toplevel: undefined variable - a" should
    appear in the CIW when trying to access the variable a)
     
    bennys, Oct 31, 2005
    #1
  2. a='unbound

    would do it.

    Andrew.
     
    Andrew Beckett, Oct 31, 2005
    #2
  3. bennys

    Trevor Bowen Guest

    is there a way to remove it from the oblist?

    gc() - doesn't seem to help...
     
    Trevor Bowen, Oct 31, 2005
    #3
  4. No. Once a symbol is in the symbol table, it's there until you exit. Note, a
    variable does not have to be created for something to end up in the oblist -
    doing:

    a='someSymbol

    will put someSymbol in the symbol table (note, oblist is really a mirror of the
    internal symbol table, in list form). There is no garbage collection of symbols,
    which is why you should be very careful about using symbols as dynamic data
    structures.

    That said, doing something like this:

    a=myVar

    will also put myVar in the symbol table, with a value of unbound. So it's no
    different having an uninitialised variable than a variable which has been set to
    unbound.

    The amount of saving (in normal situations) by removing a symbol from the symbol
    table is likely to be very small, so there is little benefit in doing this.

    Regards,

    Andrew.
     
    Andrew Beckett, Oct 31, 2005
    #4
  5. bennys

    Trevor Bowen Guest

    Thanks for the insight, Andrew!

     
    Trevor Bowen, Oct 31, 2005
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.