Skip to content

Collaborate with extension proposal #18

Open

Description

@legendecas

Congratulations on stage 1! 🎉

First of all, I'm strongly supportive of the bind operator things, it is a very good supplementary to the language. Both this proposal and extension proposal has a very similar motivation and similar design, similar semantics on the :: operator. @hax mentioned that the parallel namespace is not an essential part of the extension proposal and can be removed under the temperature of the committee. And the significant difference between the two proposals is the semantics of binding accessors. I'm wondering if it is better for two proposals to collaborate and find a consensus?

Activity

  1. js-choi commented on Oct 27, 2021

    @js-choi
    Collaborator

    @legendecas: Thanks for raising this! @hax (the champion of Extensions) and I have indeed been discussing privately, since August, about ways to reconcile our two proposals. (See also my detailed comparison document.)

    I think it would be a great idea for us to continue those discussions publicly in this issue, though.

    (@hax has said that their free time will be scarce over the next several months, which I will definitely try to respect with regards to advancing this proposal. ^_^)

  2. ljharb commented on Oct 27, 2021

    @ljharb
    Member

    The major differences seem to be the namespace, extraction, and special affordance for getters/setters. The former has strong pushback, the middle doesn't seem to have compelling motivation yet, and the latter doesn't seem to warrant special treatment (this is a combo of my opinion and my estimation of committee temperature).

    Are there other differences I've missed?

  3. js-choi commented on Oct 27, 2021

    @js-choi
    Collaborator

    @hax has said that they are open to dropping the special namespace (not sure about the special polymorphic extraction/calling syntaxes)—it’s the special treatment of getters/setters that’s the crux, perhaps.

  4. nkitku commented on Nov 11, 2021

    @nkitku
  5. js-choi commented on Nov 12, 2021

    @js-choi
  6. js-choi commented on Nov 12, 2021

    @js-choi
    Collaborator

    As the extensions section (and the in-depth comparison) say, the concrete
    differences between bind-this and extensions are currently:

    1. Bind-this has no special variable namespace (but @hax is willing to drop this).
    2. Bind-this has no implicit syntactic handling of property accessors.
    3. Bind-this has no polymorphic const ::{ … } from …; syntax.
    4. Bind-this has no polymorphic …::…:… syntax.
    5. Bind-this has no Symbol.extension metaprogramming system.

    @hax is willing to drop the first difference, but I’m not yet sure whether he would be willing to drop anything else from the list above. But I plan to keep engaging with him over the next few months, time permitting.

  7. js-choi commented on Mar 18, 2022

    @js-choi
    Collaborator

    An update: I, @tabatkins, and @hax recently wrote articles about the dataflow proposals, including bind-this and Extensions, and TC39 also held two two meetings about the dataflow proposals:

    We will discuss the two proposals further at the next plenary at the end of this month.

  8. hax commented on Mar 29, 2022

    @hax
    Member

    Note, as the recent change from bind-this to call-this, the semantic of this proposal is now the subset of extensions proposal, and the syntax of this proposal also could be compatible with extensions proposal, if we choose "receiver-first style (bracketed)" like rec::[fn](arg0). ( :: is bikeshed, if we choose ->, it would be rec->[fn](arg0). )

  9. bergus commented on Mar 29, 2022

    @bergus

    I must say I really dislike the bracketed syntax. Using parenthesis (rec::(getFn())(arg0)) should be allowed, but not required for identifiers (rec::fn(arg0)) and member expressions (rec::namespace.fn(arg0), rec::namespace["fn"](arg0)).

  10. hax commented on Mar 29, 2022

    @hax
    Member

    @bergus As extensions proposal, it also have rec::method() syntax so the pair of rec::method() and rec::[method]() is actually mapping the rec.method() and rec[method]() syntax.

  11. js-choi commented on Mar 29, 2022

    @js-choi
    Collaborator
  12. bergus commented on Mar 30, 2022

    @bergus

    @hax Are you referring to this thing? I don't quite understand why rec::[method]() uses bracket syntax - it doesn't appear to evaluate method to a property name. I think it would make sense in rec::namespace:[nameExpr](...args), desugaring to Call(GetOwnProperty(namespace, nameExpr).value, rec, args) (or GetExtension instead of GetOwnProperty), but not without a namespace object in which the property name is resolved (since we don't want to resolve it on the receiver).

  13. hax commented on May 24, 2022

    @hax
    Member

    @bergus Yes. v::ns:[expr] is also possible, or required if we have strong symbol use cases (see tc39/proposal-extensions#11).

    Syntax rec::method / rec::[method] choose [] is just for matching v.method / v[method]. But you are right, rec::[method] doesn't evaluate method to key but evaluate method to the method (or accessor) directly.

    Of coz, we could consider other brackets syntax if we want to keep [x] alway mean evaluating key: rec::(method), rec::{method}, rec::${method} (pattern match proposal use syntax like that) or even rec::<method> (turbofish! 😂 ), it's just like the current escape hatch syntax of decorators @(decorator).

  14. js-choi commented on Jul 10, 2022

    @js-choi
    Collaborator

    Syntax rec::method / rec::[method] choose [] is just for matching v.method / v[method]. But you are right, rec::[method] doesn't evaluate method to key but evaluate method to the method (or accessor) directly.

    (For what it’s worth, I actually see some value in an analogy of bound functions acting as pseudo-“methods” of their objects, with the original functions acting as pseudo-“keys”. For example, in rec::fn(), the fn would be acting like a “key” on the “method” rec::fn, before being called.
    However, I got some pushback from some others in the Committee about this analogy, so I dropped my pushing it.)

  15. hax commented on Jul 11, 2022

    @hax
    Member

    @js-choi I think the problem may be "bound" is unrelated semantic (of method), and I'm not sure the pushback is because such analogy, my impression is some delegates don't like "free" method. Actually I also feel "free" methods are not common in JS ecosystem, this is why extensions have a special syntax constraints to make it not as "free" as normal functions, one of my design goal is to make the extension users can only use extension methods as "method", not "function" by default.

  16. ewinslow commented on Mar 16, 2026

    @ewinslow

    I must say I really dislike the bracketed syntax. Using parenthesis (rec::(getFn())(arg0)) should be allowed, but not required for identifiers (rec::fn(arg0)) and member expressions (rec::namespace.fn(arg0), rec::namespace["fn"](arg0)).

    If we require parens for member expressions, that to me drops the biggest conflict with the extensions proposal, which includes a way to do extension getters/setters.

    We lose nothing by accepting this requirement. It avoids a whole lot of potential precedence confusion, avoids conflict with the extensions proposal, and doesn't block us from removing parens later if we feel that is justified.

  17. js-choi commented on Mar 16, 2026

    @js-choi
    Collaborator

    I’m open to requiring parentheses around property access chains in call-this’s RHS, in the spirit of compatibility with the extensions proposal.

    And the RHS parentheses can always be made optional for property chains, if the extensions proposal does not eventually progress.

    I would also be interested to know how @ljharb feels about this restriction for his use cases.

  18. ljharb commented on Mar 16, 2026

    @ljharb
    Member

    I suppose I'm comfortable with the parens, but the extensions proposal's current proposed solution (a parallel binding namespace) is an utter nonstarter, and I've yet to see a direction for that proposal that is worth further discussion. If that proposal has something different in mind, then it'd be great to see these two work together.

    That said, this one is more basic and simpler, so I think it would be perfectly fine to advance this one as-is and let the extensions proposal adapt around it.

  19. hax commented on Mar 26, 2026

    @hax
    Member

    @js-choi : I plan to remove "parallel binding namespace", only keep syntax like obj.ext%%prop (%% as a placeholder) in extensions proposal. I hope it could not only solve @ljharb 's concern, but also make extensions and call-this complementary.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions