all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kevin Rodgers <kevin.d.rodgers@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Is it necessary to reset or clear the global variables ?
Date: Tue, 14 Dec 2010 21:44:51 -0700	[thread overview]
Message-ID: <ie9h3s$thn$1@dough.gmane.org> (raw)
In-Reply-To: <2f54fa25-64b1-4729-9e5a-326c2ce57152@j21g2000vba.googlegroups.com>

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




      reply	other threads:[~2010-12-15  4:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-27  1:39 Is it necessary to reset or clear the global variables ? Fren Zeee
2010-12-15  4:44 ` Kevin Rodgers [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='ie9h3s$thn$1@dough.gmane.org' \
    --to=kevin.d.rodgers@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.