참조 된 변수가 전역 적으로 범위를 벗어나지 않는 한 왜 변수에 대한 참조를 선언하고 사용할 수 없습니까?AppleScript에서 핸들러에 대한 변수 참조를 선언 할 수없는 이유는 무엇입니까?
스크립트 A가 실패 :
on foo()
set l to {0}
set lref to a reference to l
return item 1 of lref
end foo
foo()
스크립트 B는 성공 :
on run
set l to {0}
set lref to a reference to l
return item 1 of lref
end run
스크립트 C는 성공 :
on foo()
global l
set l to {0}
set lref to a reference to l
return item 1 of lref
end foo
foo()
다음과 같은 현상에 이르게 런타임 메모리 또는 객체 구조를 설명해주십시오
참조 : How do you efficiently build a list within a handler in AppleScript? 및 Why Can't AppleScript make firstValue of hash into type reference in this test code?
[Applescript 개체가 정의되기 전에 어떻게 참조 할 수 있습니까?]라는 질문에 대한 근본적인 질문이 있습니다. (http://stackoverflow.com/questions/26973089/how-can-applescript-objects-be-referenced-before- they-are-defined/27237170 # 27237170) –