Undefining a variable a pointer points to [message #39333] |
Fri, 14 May 2004 14:07  |
Benjamin Hornberger
Messages: 258 Registered: March 2004
|
Senior Member |
|
|
Hi all,
is there a way to undefine the variable a pointer points to? E.g., if I
initialize a pointer by
p = ptr_new(/allocate_heap)
p is a valid pointer, but *p is undefined. If I now do
*p = 10
is there a way to undefine it again afterwards, i.e. get back to the
status right after the call to ptr_new(/allocate_heap)?
Thanks for your help,
Benjamin
|
|
|
Re: undefining a variable [message #50110 is a reply to message #39333] |
Wed, 13 September 2006 09:21  |
MarioIncandenza
Messages: 231 Registered: February 2005
|
Senior Member |
|
|
Elegance certainly has its place. When you are dusting off a routine
you may have written eight years ago, and you say, 'Now why the devil
did I just set that entire huge structure = 0?', you'd better hope you
commented your code (boo!), or else used a nice intuitive command like
UNDEFINE() (yay!).
David Fanning wrote:
> Gianguido Cianci writes:
>
>> undefine.pro is clever, but sometimes it is sufficient to set that var
>> to a scalar value. That frees up the memory, though it won't free up
>> the name :-) I haven't needed undefine so far so I thought I'd post my
>> 2 cents.
>
> UNDEFINE wasn't written because it was "needed". It
> was written because it was "elegant". :-)
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: undefining a variable [message #50115 is a reply to message #39333] |
Tue, 12 September 2006 18:25  |
cgguido
Messages: 195 Registered: August 2005
|
Senior Member |
|
|
David Fanning wrote:
> UNDEFINE wasn't written because it was "needed". It
> was written because it was "elegant". :-)
>
Sorry, I mean't clever AND elegant. Of course. But the stuff you guys
come up with is always more elegant (and clever) than by dumb for-loop
approaches ;-) I am getting too used to it and forgot to mention it....
Gianguido
|
|
|
Re: undefining a variable [message #50121 is a reply to message #39333] |
Tue, 12 September 2006 08:35  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Gianguido Cianci writes:
> undefine.pro is clever, but sometimes it is sufficient to set that var
> to a scalar value. That frees up the memory, though it won't free up
> the name :-) I haven't needed undefine so far so I thought I'd post my
> 2 cents.
UNDEFINE wasn't written because it was "needed". It
was written because it was "elegant". :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: undefining a variable [message #50122 is a reply to message #39333] |
Tue, 12 September 2006 08:27  |
cgguido
Messages: 195 Registered: August 2005
|
Senior Member |
|
|
undefine.pro is clever, but sometimes it is sufficient to set that var
to a scalar value. That frees up the memory, though it won't free up
the name :-) I haven't needed undefine so far so I thought I'd post my
2 cents.
Gianguido
|
|
|
|
|