[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
let vs. local
Hi,
I've been trying to get to grips with the let/local distinctions in
es, and have come up with the following `problem'. Why are the
following two function defintions different?
1) fn xx {echo hello; let(fn-xx=) xx; echo bye}
2) fn xx {echo hello; local(fn-xx=) xx; echo bye}
The first gives me (as expected)
hello
xx not found
bye
and the second prints `hello' ad infinitum.
I find this confusing as these two examples are `equivalent':
1) fn xx {echo hello; let(yy=bye) echo $yy}
2) fn xx {echo hello; local(yy=bye) echo $yy}
Could anyone explain why redefining the function in let/local, then calling
that function give differing results?
I stumbled on this problem when I was trying to translate rc's ``builtin''
keyword, I was trying to convert:
fn rm {builtin rm -i $*} for rc
to
fn rm {local(fn-rm=) rm -i $*} for es.
Replacing local with let works though :-).
Confused,
Pete.