all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Is it necessary to reset or clear the global variables ?
@ 2010-11-27  1:39 Fren Zeee
  2010-12-15  4:44 ` Kevin Rodgers
  0 siblings, 1 reply; 2+ messages in thread
From: Fren Zeee @ 2010-11-27  1:39 UTC (permalink / raw)
  To: help-gnu-emacs

Friends,

I am trying to modify or improve an existing lisp function written by
myself a few years ago. I have observed that when I run it on the test
data after some modification, it appears to run because the global
variables have old value and some regular expression or result did not
produce a nil or did produce a nil which resulted in the failure of
the function to die or crash during execution.

A standard method is to reset all global variables.

As a newbie, I ask you to provide me with advice on what is a good
practice.

Franz Xe

P.S. Is the word persistence an accurate term to describe this
disease ?


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Is it necessary to reset or clear the global variables ?
  2010-11-27  1:39 Is it necessary to reset or clear the global variables ? Fren Zeee
@ 2010-12-15  4:44 ` Kevin Rodgers
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Rodgers @ 2010-12-15  4:44 UTC (permalink / raw)
  To: help-gnu-emacs

On 11/26/10 6:39 PM, Fren Zeee wrote:
> Friends,
>
> I am trying to modify or improve an existing lisp function written by
> myself a few years ago. I have observed that when I run it on the test
> data after some modification, it appears to run because the global
> variables have old value and some regular expression or result did not
> produce a nil or did produce a nil which resulted in the failure of
> the function to die or crash during execution.
>
> A standard method is to reset all global variables.
>
> As a newbie, I ask you to provide me with advice on what is a good
> practice.

If you do not need to persist state across calls to the function, do
not use global variables.  Passing state information to the function
via its arguments is better than accessing it via global variables.

> Franz Xe
>
> P.S. Is the word persistence an accurate term to describe this
> disease ?

Persistence is neither diseased nor healthy.

-- 
Kevin Rodgers
Denver, Colorado, USA




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-12-15  4:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-27  1:39 Is it necessary to reset or clear the global variables ? Fren Zeee
2010-12-15  4:44 ` Kevin Rodgers

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.