public Sequence<? extends Item> eval(Sequence<? extends Item> contextSeq, DynamicContext dynEnv)
throws XQueryException {
LetVariable lv = (LetVariable) _variable;
XQExpression letExpr = lv.getValue();
Sequence<? extends Item> res = letExpr.eval(contextSeq, dynEnv);
if(lv.attemptEagarEvaluation() && lv.getReferenceCount() > 1) {
List<? extends Item> items = res.materialize(); // TODO REVIEWME weak memory utilization
lv.allocateResult(new ValueSequence(items, dynEnv), dynEnv);
} else {
lv.allocateResult(res, dynEnv);