On Jun 15, 2011, at 8:36 AM, Axel Rauschmayer wrote:

>> The point is that the callSiteId captures all the 
>> literal/constant/loop-invariant parts of the quasi, both raw and cooked 
>> ("expandedLP"). The remaining quasi handler parameters are the necessarily 
>> variable, evaluated-at-runtime substitution expression results.
> 
> 
> That makes sense. The ID then allows one to do caching. But I don’t see how 
> the same quasi-literal can be “invoked” multiple times.

In a loop:

  for (let i = 0; i < N; i++) {
    let sub0 = i * 2, sub1 = i * i;

    results[i] = re_match`lp0${sub0}lp1${sub1}lp2`(targets[i]);
  }

Remember the quasi handler is just a function, here named re_match, found as 
usual by lexical scope. The invariant parts (raw and cooked) are collected and 
hoisted, given a unique name behind the scenes so they can be passed as an 
object, as the first actual parameter. The remaining arguments are sub0 and 
sub1evaluation results, which definitely vary per iteration.

/be

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to