Hi Dean,

On Sat, Dec 17, 2016 at 06:02:29PM +0000, dean wrote:
> #{Is it possible to change a list AND keep it's name the same at different
> program levels}#
> (setq L '(a))
> (de doit_temp (L) (prog (setq L (append L '(b))) (prinl "inside of fn L is
> " L))  )
> (de doit_perm (L) (setq NewL (append L '(b))))
> (doit_temp L)
> (prinl "outside of fn L is " L)
> (doit_perm L)
> (prinl "outside of fn NewL is " NewL)
> 
> #inside of fn L is ab
> #outside of fn L is a
> #outside of fn NewL is ab

Hmm, again I can't really understand what your question is. And you seem to use
the wrong terminology.

The key concept is "symbol binding". Let me try to clear some things up:


> #{Is it possible to change a list AND keep it's name the same at different
> program levels}#

A list does not have a "name". You can only *bind* a symbol to a list.

Binding is fundamental concept of Lisp, and you should *really* try to
understand it thoroughly before writing any programs. Please study the example
code in the distro and at rosettacode.org!


> (setq L '(a))

This binds the symbol 'L' globally to the list '(a)'.



> (de doit_temp (L)
>    (prog
>       (setq L (append L '(b)))
>       (prinl "inside of fn L is " L) ) )

(The 'prog' is not needed)

The symbol 'L' is bound to some value when the function is called. Then it is
extended by appending '(b)' to whatever value that is. That is printed, then 'L'
is restored upon function return to whatever global value it had before.


> (de doit_perm (L)
>    (setq NewL (append L '(b))) )

'NewL' is global from this function.

It should be named *NewL according to the PicoLisp naming conventions.



All this explains the output you get :)

- Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to