lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Dibyendu Majumdar <mobile@majumdar.org.uk>于2018年4月12日周四 下午8:32写道:
But of course the AST can be used for other purposes too - for
instance by someone else that needs it ... in that case a different
strategy is necessary. But you are right I could cache the source
string / and AST as a pair - and just rebuild AST from source if
necessary. But I will need to hang on to the source until ... ?


I think source strings are native lua objects, so just use a weak table to cache this pair (string/AST) is ok. Even if you haven't make this cache, you should also wait lua gc to collect source strings.