Can special variables hi-jack function parameters?
- From: "webmasterATflymagnetic.com" <webmaster@xxxxxxxxxxxxxxx>
- Date: Tue, 5 Aug 2008 16:28:28 -0700 (PDT)
I'm not sure I understand this, but it seems to me that special
variables can override parameter values in defun functions. If I set
up this variable and two functions:
(defvar *x* 10)
(defun a (*x*) (b))
(defun b () *x*)
When I enter (a 4) I get:
1. Trace: (A '4)
2. Trace: (B)
2. Trace: B ==> 4
1. Trace: A ==> 4
4
[40]> *x*
10
This seems to imply that the parameter call to a (ie *x*) is
remembered when function b is called, but forgotten about after a
terminates. In other words *x* in b knows about the parameter getting
the value 4, even though it doesn't get it directly.
Is this correct?
If so it seems care needs to be taken when defining parameter values
to make sure their names don't conflict with any special variables
that have been set up.
I hope the above makes sense -- it goes against what I would have
intuitively expected, with function parameters 'protected' by being
local to the function. I would have expected the *x* value in a to be
ignored, and b to print out 10 as if nothing had been passed to a.
.
- Follow-Ups:
- Re: Can special variables hi-jack function parameters?
- From: Drew Crampsie
- Re: Can special variables hi-jack function parameters?
- Prev by Date: Re: "beta" is a reach, but....
- Next by Date: Re: Can special variables hi-jack function parameters?
- Previous by thread: [ANN] ECL 0.9l
- Next by thread: Re: Can special variables hi-jack function parameters?
- Index(es):