william@ashtate (William Wong) (05/18/91)
I got a question about Catch and Throw with loading file. Let's say I install a (Catch 'Name1) in a function, and later, does a (load "file1") in the same function. Now if I do a (Throw 'Name1) in "file1," where does the control flow go? Does it go back to (Catch 'Name1)? Or does it say "couldn't find Name1"? In CLtL2, it says Catch/Throw have no scope. I am wondering whether Load is considered the same as the function in terms of lexical scope. William
barmar@think.com (Barry Margolin) (05/18/91)
In article <1991May18.003253.4124@ashtate> william@ashtate.UUCP (William Wong) writes: >I got a question about Catch and Throw with loading file. Let's say I >install a (Catch 'Name1) in a function, and later, does a (load "file1") >in the same function. Now if I do a (Throw 'Name1) in "file1," where >does the control flow go? Does it go back to (Catch 'Name1)? Or does it >say "couldn't find Name1"? It returns from the CATCH. Any THROW that occurs during the dynamic extent of a matching CATCH will return from the CATCH. >In CLtL2, it says Catch/Throw have no scope. I am wondering whether Load >is considered the same as the function in terms of lexical scope. I'm not sure how to interpret this question, or what its relevance is. You just said, correctly, that CATCH tags aren't lexically scoped, so why does it matter which lexical scope the file is in? But to clarify, lexical scope, by definition, is not dependent upon runtime invocation order. Every top-level form in a file being loaded defines its own lexical scope, which only includes the forms textually visible within that top-level form. Since the contents of a different file are not textually enclosed within the form containing the LOAD call, they are not in the same lexical scope. Lexical scope is a purely static, syntactic property of a program. -- Barry Margolin, Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar