|Keep It Simple, Stupid|
Re: Trees and Language::AttributeGrammarby nothingmuch (Priest)
|on Mar 06, 2006 at 17:56 UTC||Need Help??|
First of all, the fix is this:
As you can see mentioning $/, the attribute's invocant fixes this.
You're probably asking yourself why...
Comparing the two versions shows us something interesting:
So, what is the void thingy doing in there, you are probably wondering? Aha!
Basically, $_AG_SELF causes the value to remain non-garbage collected (since it's captured in the closure it's reference count stays up). Since luqui is using a lazy evaluation strategy to produce results, and this probably means that somewhere inside $_AG_ATTR or whatever there's a table of objects to their attr values, the moment that $_AG_SELF dies (and it will die, because you are creating Cons thingies on the fly inside 'children') it can no longer be referenced in a thunk, because it's StrVal cannot be reproduced. Anyway, long story short, the evaluation scheme is somehow landing on an edge case with two children in the Cons/Nil thing, and thus it's causing the value to be recalculated over and over and over and over again. I think.
The more elegant fix is to cache your linked list, something like
so that the values don't go away. Remember to invalidate _ll_cache whenever new children are added.
zz zZ Z Z #!perl