Arc Forumnew | comments | leaders | submitlogin
3 points by eds 5915 days ago | link | parent

Maybe I missed the point of your post, but if you just want temporary variables inside a block of code, can't you just use let?

  (let var val
    ; use var
  )
  ; now var is gone
Or use with if you want to declare mutliple variables.

This works if what you want is temporary local variables. (And it's better than tempset because it uses the stack to restore previous values of variables, and can create nested scopes.)

If on the other hand you are talking about creation of temporary global variables, then you might need something a little fancier.

Or perhaps you are talking about something like unintern from CL? I admit it might be kind of nice to have explicit intern and unintern primitives. But that is more of a namespace issue than merely an unsetting a variable.



4 points by lacker 5915 days ago | link

Yeah, like unintern from CL. Although more closely something like python's del.

in python:

  >>> a = 3
  >>> a
  3
  >>> del a
  >>> a
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
  NameError: name 'a' is not defined

edit: I investigated a little more and found mzscheme's namespace-undefine-variable! I think this is going to work. Thanks for the hint ;-)

-----