In most cases, name resolution based on lexical scope is relatively straightforward to use and to implement, as in use one can read backwards in the source code to determine to which entity a name refers, and in implementation one can maintain a list of names and contexts when compiling or interpreting a program. Difficulties arise in name masking, forward declarations, and hoisting, while considerably subtler ones arise with non-local variables, particularly in closures.
iN most Cases, NAme resOLUtion basED on LexIcal scOpE is ReLAtIVEly strAightfoRWArD TO UsE AnD to implement, As in USe one can read backWArds In tHe source codE tO deTeRMIne to whiCh entity a nAME ReFErs, ANd iN ImplementATioN OnE can MaIntaIn a list of Names And contexts when compiLiNg oR IntErpREting a prOGram. dIffiCUlTIes AriSe in nAmE Masking, fOrWaRd declarations, aND HoISTiNG, while considerAbLy SubTleR onEs aRiSe wiTh NOn-local vARiaBles, partIcularlY IN CLOsureS.