On 14-02-07 03:15 PM, Allen Wirfs-Brock wrote:
The Yield parameter selects whether or not "yield" is treated as an identifier or as an operator symbol. "yield" is only treated as an operator if the yield parameter is present.
Yup, got that.
The GeneratorParameter parameter, when present, tags the use of a production in the parameter list. A yield operation doesn't work as part of an initializer or computed property name in a generator function's parameter list because when parameter declarations are evaluated, the associated generator object is not yet in a yield-able state.
Yup, got that from the Note in 14.4. However, I was puzzled, because it implies that you don't want +Yield to propagate to AssignmentExpressions within the parameter list, and yet that's exactly what's being 'passed' to the Strict/FormalParameters symbols. So it would be useful to augment that Note with something like your next paragraph:
However, to avoid confusion, we want to disallow the use of "yield" as an identifier throughout a generator function including the parameter list. So, we parameterize StrictFormalParameters for generator functions and methods with [Yield, GeneratorParameter]. That parameter combination can be interpreted as don't allow "yield" as an identifier but also don't allow it to be used as an operator.
[I'm going to abbreviate "GeneratorParameter" here as "GP".] Looking at it some more, I think it nearly doesn't matter whether StrictFormalParameters is 'invoked' with or without 'Yield'. Generally, at any point where you stop propagating the GP parameter, there's a [+GP] rhs-annotation that explicitly says whether or not to pass down 'Yield'. I think the only exception is when FormalParameterList invokes FunctionRestParameter -- if you added [+GP] annotations to that production, then the presence/absence of 'Yield' wouldn't matter at all when 'GP' is present. (Alternatively, you could give FunctionRestParameter a GP parameter, and do simple propagation from FormalParameterList to FunctionRestParameter to BindingRestElement, which already has a [+GP] annotation.) [[ I noticed that BindingRestElement doesn't really need its GP parameter -- regardless of parameters, it *can't* derive a YieldExpression, so it only needs to know whether to allow 'yield' as an identifier, which can be done with just the 'Yield' parameter. But I'm guessing you gave it a GP because it's tidier to do the [+/-GP] split there than in ArrayBindingPattern. Similarly, I don't think PropertyName needs a GP parameter, but it's slightly tidier to do the [+/-GP] split there than in BindingProperty. ]] One thing I still don't understand: why does GeneratorExpression invoke BindingIdentifier with Yield but GeneratorDeclaration invokes it without? -Michael _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

