Re: New batch of skill questions - appreciate your help
by pxhxz@[EMAIL PROTECTED]
(Pete nospam Zakel)
Apr 28, 2008 at 05:42 PM
In article <1209371450_3825@[EMAIL PROTECTED]
>
stephane.badel@[EMAIL PROTECTED]
writes:
>> Q1. When I define two procedures as following: procedure( proc1()
>> x=10) and the other is: procedure(proc2() x); if i called the first
>> one (i.e. proc1) it will return the value of the variable x defined
>> there, why when i call proc2 it gives me error that variable x is
>> undefined? Although i am not using either prog or let for making it
>> local? I think i misunderstand the concept! How to let a variable
>> global?
>No... it should really work...
x won't be defined until after you invoke proc1(). Just declaring x
within
a statement in proc1() doesn't define it:
# skill
> procedure( proc1() x=10)
proc1
> procedure(proc2() x)
proc2
> x
*Error* toplevel: undefined variable - x
> proc2()
*Error* eval: unbound variable - x
> proc1()
10
> x
10
> proc2()
10
However, I wouldn't use "x" as a global since it's likely to be clobbered
by other routines. And you shouldn't begin any globals you create with a
lowercase letter.
-Pete Zakel
(phz@[EMAIL PROTECTED]
)
"Walking on water and developing software from a specification are easy
if both are frozen."
-Edward V. Berard