```From: Javier Fernandez
Subject: variable actualization problem
Date: Tue, 11 Mar 1997 00:00:00 +0000
Message-ID: <3325D52A.703E@kender.es>```
```Hello:

I'm learning Lisp and I don't know much about it,
I'd like that somebody explains me the next situation:

I got four functions:

;********************************************************
(DEFUN LEER (CINTA POS)
(NTH POS CINTA)
)
;********************************************************
(DEFUN ESCRIBIR (CINTA POS SIMBOLO)
(APPEND (BUTLAST CINTA (- (LENGTH CINTA) POS))
(LIST SIMBOLO)
(NTHCDR (+ POS 1) CINTA)
)
)
;********************************************************
(DEFUN Q1 (CINTA POS)
(COND	((EQUAL (LEER CINTA POS) '^)
(Q2 CINTA (+ POS 1)))
)
)
;********************************************************
(DEFUN Q2 (CINTA POS)
(COND	((EQUAL (LEER CINTA POS) 1)
(Q3 (ESCRIBIR CINTA POS '^) POS))
((EQUAL (LEER CINTA POS) '^)
(QH (ESCRIBIR CINTA POS 'X) POS))
)
)
;********************************************************

when I invoke Q1 function all goes good, but imagine you that
all before functions are defined as i wrote before except Q1
that it's defined in the next way:

(DEFUN Q1 (CINTA POS)
(COND	((EQUAL (LEER CINTA POS) '^) (+ POS 1)
(Q2 CINTA POS))
)
)

My question is: why the Q2 function is now invoked without
actualize the value of POS? Cos if I write (+ POS 1) before
(Q2 CINTA POS) it's reasonable to think that in the espresion
(Q2 CINTA POS) the value of POS be one more unit than the value
passed to the Q1 function.

Well, thank you

I'm beginner in Lisp programming and i got many doubts so
i'd like somebody explains me what i've said. Excuse my english.

Javi```
```From: Gareth McCaughan
Subject: Re: variable actualization problem
Date: Wed, 12 Mar 1997 00:00:00 +0000
Message-ID: <86ohcpwb6j.fsf@g.pet.cam.ac.uk>```
```Javier Fernandez <········@kender.es> writes:

> (DEFUN Q1 (CINTA POS)
> 	(COND	((EQUAL (LEER CINTA POS) '^) (+ POS 1)
> 					(Q2 CINTA POS))
> 	)
> )
>
>
> My question is: why the Q2 function is now invoked without
> actualize the value of POS? Cos if I write (+ POS 1) before
> (Q2 CINTA POS) it's reasonable to think that in the espresion
> (Q2 CINTA POS) the value of POS be one more unit than the value
> passed to the Q1 function.

It may be reasonable, but it's wrong. Evaluating (+ POS 1) just
returns POS+1; it doesn't change the value of POS. Things only
get changed when you actually ask for them to be.

It's like in mathematics; if you write the two equations
y = f(x+1)
z = a+b+x
the value of x hasn't changed between the first line and the second,
even though you did something using x+1.

--
Gareth McCaughan       Dept. of Pure Mathematics & Mathematical Statistics,
·····@dpmms.cam.ac.uk  Cambridge University, England.```