New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review of function.sent #204

Open
littledan opened this Issue Nov 18, 2015 · 20 comments

Comments

Projects
None yet
7 participants
@littledan
Member

littledan commented Nov 18, 2015

Opening this thread to put a review of the function.sent proposal
@bterlson @domenic

  • Probably you should attach LastYieldValue as an internal slot of the GeneratorObject (in Table 56), rather than in Table 24. This is an aesthetic judgement, though.
  • There are a couple cases where function.sent can have a default undefined value visible. Was this intentional? Should we get a TDZ in these cases, or is undefined the intention? I have no preference here.
    • after calling generator.return(), in the finally block
    • in default argument evaluation for the generator
@littledan

This comment has been minimized.

Show comment
Hide comment
@littledan

littledan Nov 18, 2015

Member

Also, sounds like function.sent can't be used from an eval inside the generator, in this spec text, since it wouldn't be produced by the grammar. I'm happy with that decision, but I wanted to double-check that that was the intention.

Member

littledan commented Nov 18, 2015

Also, sounds like function.sent can't be used from an eval inside the generator, in this spec text, since it wouldn't be produced by the grammar. I'm happy with that decision, but I wanted to double-check that that was the intention.

@bterlson

This comment has been minimized.

Show comment
Hide comment
@bterlson

bterlson Nov 19, 2015

Member

I like undefined over exception, personally. It would be pretty easy to change this to throw for those cases (strawman: GeneratorStart and GeneratorYield set the slot to Empty rather than undefined, and function.sent can throw if it sees Empty). I am having trouble coming up with a strong rationale for either side. Wonder what @allenwb thinks?

Given that you can't yield from eval I wouldn't expect that you can function.sent in eval either.

Member

bterlson commented Nov 19, 2015

I like undefined over exception, personally. It would be pretty easy to change this to throw for those cases (strawman: GeneratorStart and GeneratorYield set the slot to Empty rather than undefined, and function.sent can throw if it sees Empty). I am having trouble coming up with a strong rationale for either side. Wonder what @allenwb thinks?

Given that you can't yield from eval I wouldn't expect that you can function.sent in eval either.

@rossberg

This comment has been minimized.

Show comment
Hide comment
@rossberg

rossberg Nov 19, 2015

Member

I think things like new.target and function.sent should consistently work like lexically scoped variables with fancy names. In that sense, it would be rather odd if they weren't accessible from an eval.

Member

rossberg commented Nov 19, 2015

I think things like new.target and function.sent should consistently work like lexically scoped variables with fancy names. In that sense, it would be rather odd if they weren't accessible from an eval.

@anba

This comment has been minimized.

Show comment
Hide comment
@anba

anba Nov 19, 2015

Contributor

in default argument evaluation for the generator

This is not possible in the current draft because of the [Yield] production parameter restriction.

Contributor

anba commented Nov 19, 2015

in default argument evaluation for the generator

This is not possible in the current draft because of the [Yield] production parameter restriction.

@bterlson

This comment has been minimized.

Show comment
Hide comment
@bterlson

bterlson Nov 19, 2015

Member

@rossberg-chromium yeah I agree in principle that this should probably work inside eval, but it would mean we can't throw a syntax error for function.sent outside of generator bodies without much effort. Would you say it's ok for function.sent to work like new.target in the sense that it is allowed everywhere, returns undefined when not inside a generator, and store [[LastYieldValue]] on the lexical environment rather than execution context?

Also means the following works:

function* foo() {
  let thunk = () => function.sent;
  yield;
  thunk();
}

Seems ok?

Member

bterlson commented Nov 19, 2015

@rossberg-chromium yeah I agree in principle that this should probably work inside eval, but it would mean we can't throw a syntax error for function.sent outside of generator bodies without much effort. Would you say it's ok for function.sent to work like new.target in the sense that it is allowed everywhere, returns undefined when not inside a generator, and store [[LastYieldValue]] on the lexical environment rather than execution context?

Also means the following works:

function* foo() {
  let thunk = () => function.sent;
  yield;
  thunk();
}

Seems ok?

@rossberg

This comment has been minimized.

Show comment
Hide comment
@rossberg

rossberg Nov 20, 2015

Member

Treating it like a fancily named variable would imply that it is simply unbound outside any generator. That is, it would yield a static ReferenceError in strict mode, or a dynamic ReferenceError in sloppy mode.

Member

rossberg commented Nov 20, 2015

Treating it like a fancily named variable would imply that it is simply unbound outside any generator. That is, it would yield a static ReferenceError in strict mode, or a dynamic ReferenceError in sloppy mode.

@allenwb

This comment has been minimized.

Show comment
Hide comment
@allenwb

allenwb Nov 20, 2015

Member

There are a couple cases where function.sent can have a default undefined value visible. Was this intentional? Should we get a TDZ in these cases, or is undefined the intention? I have no preference here.
after calling generator.return(), in the finally block

I believe the finally after generator.return is the only place this is observable. This was not intentional.

However, the only reason that I specified that GeneratorYield should set LastYieldValue to undefined was to keep from memory leaking the current LastYieldValue in case the generator object (and associated) context was retained but never activated again. However, I was assuming that setting it to undefined was unobservable.

Given that it is observable and that the generator context is also potentially memory leaking all the state referenced from its local variable bindings I don't think we should be concerned about plugging that one potential leak source.

I suggest that we simply delete from the proposal the change to GeneratorYield. Then finally blocks will see the last actual sent value via function.sent and the memory leakage potential of function.sent is the same as any local variable of the generator function.

Member

allenwb commented Nov 20, 2015

There are a couple cases where function.sent can have a default undefined value visible. Was this intentional? Should we get a TDZ in these cases, or is undefined the intention? I have no preference here.
after calling generator.return(), in the finally block

I believe the finally after generator.return is the only place this is observable. This was not intentional.

However, the only reason that I specified that GeneratorYield should set LastYieldValue to undefined was to keep from memory leaking the current LastYieldValue in case the generator object (and associated) context was retained but never activated again. However, I was assuming that setting it to undefined was unobservable.

Given that it is observable and that the generator context is also potentially memory leaking all the state referenced from its local variable bindings I don't think we should be concerned about plugging that one potential leak source.

I suggest that we simply delete from the proposal the change to GeneratorYield. Then finally blocks will see the last actual sent value via function.sent and the memory leakage potential of function.sent is the same as any local variable of the generator function.

@bterlson bterlson added the meta label Feb 18, 2016

@ljharb

This comment has been minimized.

Show comment
Hide comment
@ljharb

ljharb Mar 20, 2018

Member

@allenwb are you still interested in advancing function.sent? If so, it'd be great if you could make a proposal repo for it, and then we can move this thread there.

Member

ljharb commented Mar 20, 2018

@allenwb are you still interested in advancing function.sent? If so, it'd be great if you could make a proposal repo for it, and then we can move this thread there.

@allenwb

This comment has been minimized.

Show comment
Hide comment
@allenwb

allenwb Mar 20, 2018

Member

I'm generally out of the proposal writing and championing business. Assuming that the committee is still interested, somebody else should take it over.

It's a relatively small features so I suspect that one of the editors could just pick it up fairly easily.

Member

allenwb commented Mar 20, 2018

I'm generally out of the proposal writing and championing business. Assuming that the committee is still interested, somebody else should take it over.

It's a relatively small features so I suspect that one of the editors could just pick it up fairly easily.

@ljharb

This comment has been minimized.

Show comment
Hide comment
@ljharb

ljharb Mar 20, 2018

Member

Absent a champion, it should probably be considered withdrawn - I’ll add an item to this week’s agenda to ask if anyone is interested in picking it up.

Member

ljharb commented Mar 20, 2018

Absent a champion, it should probably be considered withdrawn - I’ll add an item to this week’s agenda to ask if anyone is interested in picking it up.

@allenwb

This comment has been minimized.

Show comment
Hide comment
@allenwb

allenwb Mar 20, 2018

Member

Absent a champion, it should probably be considered withdrawn

I don't think that's correct. As a stage two means: "The committee expects the feature to be developed and eventually included in the standard". A champion resigning from that role because they have become less active within TC39 is not the same thing as withdrawing the proposal and it isn't by intent to withdraw it.

If the committee wants to change it's mind it certainly can, but otherwise it needs to identify a new champion.

Member

allenwb commented Mar 20, 2018

Absent a champion, it should probably be considered withdrawn

I don't think that's correct. As a stage two means: "The committee expects the feature to be developed and eventually included in the standard". A champion resigning from that role because they have become less active within TC39 is not the same thing as withdrawing the proposal and it isn't by intent to withdraw it.

If the committee wants to change it's mind it certainly can, but otherwise it needs to identify a new champion.

@ljharb

This comment has been minimized.

Show comment
Hide comment
@ljharb

ljharb Mar 20, 2018

Member

Fair point; either way I'll ask for a champion to step up.

Member

ljharb commented Mar 20, 2018

Fair point; either way I'll ask for a champion to step up.

@littledan

This comment has been minimized.

Show comment
Hide comment
@littledan

littledan Apr 4, 2018

Member

@ljharb Thanks for bringing this up at the meeting. Have you heard any interest?

Member

littledan commented Apr 4, 2018

@ljharb Thanks for bringing this up at the meeting. Have you heard any interest?

@ljharb

This comment has been minimized.

Show comment
Hide comment
@ljharb

ljharb Apr 4, 2018

Member

Nothing yet; I’ll update here if i do.

Member

ljharb commented Apr 4, 2018

Nothing yet; I’ll update here if i do.

@littledan

This comment has been minimized.

Show comment
Hide comment
@littledan

littledan Apr 4, 2018

Member

OK, if we continue to not get a champion in the committee, I like your idea of considering it withdrawn at some point.

Member

littledan commented Apr 4, 2018

OK, if we continue to not get a champion in the committee, I like your idea of considering it withdrawn at some point.

@concavelenz

This comment has been minimized.

Show comment
Hide comment
@concavelenz

concavelenz Apr 4, 2018

concavelenz commented Apr 4, 2018

@ljharb

This comment has been minimized.

Show comment
Hide comment
@ljharb

ljharb Apr 4, 2018

Member

Techincally the category is “inactive”, and things may be inactive because they’re withdrawn, or rejected; I’m sure we could put “no champion” as the reason.

Member

ljharb commented Apr 4, 2018

Techincally the category is “inactive”, and things may be inactive because they’re withdrawn, or rejected; I’m sure we could put “no champion” as the reason.

@allenwb

This comment has been minimized.

Show comment
Hide comment
@allenwb

allenwb Apr 4, 2018

Member

What does "considering it withdrawn" mean? I don't think any real or "considered" action taken via this thread is appropriate.

TC39 in meeting and via a minuted consensus decision, promoted this proposal to Stage 2. It should require a similar decision by TC39 to change its status to something else. It is presumably the responsibility of the TC39 management team to set agenda items to address such situations. I don't believe that it is appropriate for such an agenda item to recommend "considering the proposal" withdrawn. An appropriate item for the committee would be: "XXX is no longer available to serve as champion for this stage 2 proposal. If TC39 still believe that it expects the feature to be developed and eventually included in the standard then it must appoint a new champion."

Member

allenwb commented Apr 4, 2018

What does "considering it withdrawn" mean? I don't think any real or "considered" action taken via this thread is appropriate.

TC39 in meeting and via a minuted consensus decision, promoted this proposal to Stage 2. It should require a similar decision by TC39 to change its status to something else. It is presumably the responsibility of the TC39 management team to set agenda items to address such situations. I don't believe that it is appropriate for such an agenda item to recommend "considering the proposal" withdrawn. An appropriate item for the committee would be: "XXX is no longer available to serve as champion for this stage 2 proposal. If TC39 still believe that it expects the feature to be developed and eventually included in the standard then it must appoint a new champion."

@ljharb

This comment has been minimized.

Show comment
Hide comment
@ljharb

ljharb Apr 4, 2018

Member

That is exactly how it’s going to go - i had an agenda item last month to ask for a new champion, if none arises, we’ll add an agenda item to make the proposal inactive, which would include seeking committee consensus that the feature no longer is intended to be developed and included in the language. If a champion materializes, then it’ll be a moot point.

Member

ljharb commented Apr 4, 2018

That is exactly how it’s going to go - i had an agenda item last month to ask for a new champion, if none arises, we’ll add an agenda item to make the proposal inactive, which would include seeking committee consensus that the feature no longer is intended to be developed and included in the language. If a champion materializes, then it’ll be a moot point.

@littledan

This comment has been minimized.

Show comment
Hide comment
@littledan

littledan Apr 5, 2018

Member

Thanks for taking this on, @ljharb. That strategy sounds fair to me. I am not against function.sent, but it is really helpful to have this clearly articulated and up to date metadata about what is happening with proposals.

Member

littledan commented Apr 5, 2018

Thanks for taking this on, @ljharb. That strategy sounds fair to me. I am not against function.sent, but it is really helpful to have this clearly articulated and up to date metadata about what is happening with proposals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment