11.9 영구 변수(Persistent Variables)
11.9 영구 변수(Persistent Variables)
매크로 컨텍스트는 컴파일 타임에 값을 저장하는 영구 변수를 제공합니다. 이는 Context.getLocalType()과 같은 함수에서 값을 보관하는 데 유용합니다.
import haxe.macro.Context;
class Main {
static function main() {
var t = "hello";
trace(t); // hello
}
macro static function getPersistent():String {
return Context.getLocalPersistent("t");
}
}
영구 변수는 매크로 호출 사이에 유지되며, Context.setLocalPersistent으로 설정할 수 있습니다.