Re: Delvar? [message #31363 is a reply to message #31225] |
Fri, 28 June 2002 14:07   |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
David Fanning <david@dfanning.com> writes:
> David Fanning (david@dfanning.com) writes:
>
>> Alright. First of all, this code is inside a procedure.
>> That's important. UNDEFINE looks like this:
>>
>> ;*********************************************************** *********
>> PRO UNDEFINE, varname
>> IF (N_Elements(varname) NE 0) THEN tempvar = Size(Temporary(varname))
>> END
>> ;*********************************************************** *********
>
> Oh, oh. I think my problem is that I'm not anal enough. :-(
>
> It was gently pointed out to me that, uh, the SIZE function
> isn't really doing anything worthwhile here, so why put
> it in?
Hi David--
Actually I like the SIZE() function there. If VARNAME is a large
array, then you are just wasting cycles copying it to TEMPVAR, only to
have it erased a moment later when the UNDEFINE procedure returns.
What I do often enough is the following slight variation.
;*********************************************************** *********
PRO UNDEFINE, varname
varname = 0
tempvar = temporary(varname)
END
;*********************************************************** *********
This assures that the memory associated with VARNAME is released
first, and then the TEMPORARY() call is only there to release the "0".
In the line-count contest with you, I lose, but in the character count
contest, I win!
Craig
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|