tc39 / proposal-pipeline-operator

A proposal for adding a useful pipe operator to JavaScript.
http://tc39.github.io/proposal-pipeline-operator/
BSD 3-Clause "New" or "Revised" License
7.56k stars 108 forks source link

Bikeshedding the Hack topic token #91

Open js-choi opened 6 years ago

js-choi commented 6 years ago

This issue is for bikeshedding the spelling of the topic token in Hack pipes, branching off from https://github.com/tc39/proposal-pipeline-operator/issues/75#issuecomment-362850526. For more context, see the Hack pipes proposal and the wiki home page.

The table has its own editable page on the wiki. Please read this table first before contributing to this issue.

Please also keep discussion on topic: bikeshedding the topic token for Hack pipes. For other topics, search for other existing issues. Thank you!

Old obsolete questions These currently are the [most topical bikeshedding questions](https://github.com/tc39/proposal-pipeline-operator/issues/91#issuecomment-364138000) that I see now: 1. What is the optimal tradeoff in writability (easily typed [ASCII soup, e.g., `?`](https://github.com/tc39/proposal-partial-application/issues/21#issuecomment-361092565), or easily typed privileged valid variable, e.g., `$`) versus readability (less easily inputted non-ASCII syntax, e.g., `■`)? 2. Related to question 2: Can non-ASCII Unicode syntax characters be considered for the pipe placeholder, or must they be categorically excluded? A [list of all possible `Pattern_Syntax` Unicode characters](https://unicode.org/cldr/utility/list-unicodeset.jsp?a=%5B%3APattern_Syntax%3A%5D&c=on&g=&i=) is available. 3. If question 3’s answer is that non-ASCII Unicode syntax may be excluded, which non-ASCII [syntax character](https://unicode.org/cldr/utility/list-unicodeset.jsp?a=%5B%3APattern_Syntax%3A%5D&c=on&g=&i=) would be visually understandable and/or less difficuldif­fi­cultt? Many non-ASCII symbols are easily inputted in certain OSes. For instance, in macOS, several dozen typographic characters are directly typable using Option or Option + Shift ([image of keyboards with various active modifier keys](https://images.techhive.com/images/article/2015/09/specialcharacter_2-100616180-large.png) via [Macworld article](https://www.macworld.com/article/2985301/software-graphics/how-to-access-hidden-typographic-characters-in-os-x.html). It may be worth determining if there is an intersection of these easily typable non-ASCII characters across the default keyboard layouts of many OSes. 4. For nullary operators vs. valid variable identifiers: How important is it that the placeholder be statically analyzable? A nullary operator can be always be statically recognized in the RHS. In contrast, a valid identifier can be statically recognized only if the rule is: “Tacit function calling may occur only when the RHS is a bare identifier, rather than allowing the RHS to be any arbitrary expression without a placeholder.” 5. Operator vs. identifier again: How often would someone want to use an identifier from an outer lexical context of the same name as the pipe placeholder? If the placeholder is `$`, how often would a programmer want to use jQuery’s `$` or another externally defined `$` in a pipe’s RHS, as well as the pipe placeholder? How often would they be surprised if they could not, without defining a dummy variable for the outer `$`? How bad of a footgun (i.e., bug by programmer-unexpected behavior) would this be? 6. How much should the pipe placeholder stay compatible with @rbuckton’s [higher-order functional operators](https://github.com/rbuckton/proposal-functional-operators/), which possibly would use `{…}`? 7. @rbuckton proposed a [partial-application placeholder](https://github.com/tc39/proposal-partial-application) that may be explainable by multiple topic placeholders. In other words, the pipeline syntax might be completely unifiable with the PA syntax with the right enhancements. Assuming a [future shorthand “pipe-function operator”](https://github.com/js-choi/proposal-hack-pipes/blob/master/README.md#pipe-functions) like `+>` (which would be an abbreviation for `x=>x|>`), then @rbuckton’s proposal’s `f(?, 3)` would instead be `+> f(?, 3)`, which in turn would be shorthand for `x=>x|> f(?, 3)`. Creating non-unary functions could be done by adding numbers to placeholders, such as `?0`, `?1`, `?2`, etc.\ For instance, `example.sort(+> ?0 - ?1)`\ would mean `example.sort((x, y) => x - y)`.\ (`?0` would be equivalent to plain `?`.) Which placeholders would have any problems with staying forward compatible with such a future proposal?

As of 2022-07-11, I like ^^ then more distantly $_, @@, %%, and #_.

ljharb commented 6 years ago

There's a few choices that use ? but might avoid some of the confusion:

Also, I find ^^ confusing in that what it does is not related to what ^ does.

aikeru commented 6 years ago

FWIW, I really like ^^. I find it clever, and illustrative in that it points up, as though at the previous expression which is likely to be the LHS of the pipeline operator, reminding you where the value comes from.

ljharb commented 6 years ago

Pipelines will be single-line just as often as multiline; so "points up" and "points at the previous" won't consistently be the same.

littledan commented 6 years ago

I take it that, if we go down the Hack-style path, we're not trying for any kind of path for the placeholder to be subsumed by @rbuckton's partial application proposal, and therefore should avoid using the same token, is that right?

gilbert commented 6 years ago

My 2c: I personally really like $ as the placeholder variable binding. Because it's a valid identifier, it feels like an actual variable, which it certainly is (albiet smaller in scope). It also prevents the Hack-style proposal from claiming another operator that might be useful for future proposals.

I think the "jQuery problem" is probably overblown for these reasons:

mAAdhaTTah commented 6 years ago

Is it at all possible to use $ in the partial application proposal? If we're trying to leave open the door for a partial application proposal in the future, we could end up with two different syntaxes for partial application / placeholders, one inside pipelines and one outside.

littledan commented 6 years ago

@mAAdhaTTah I don't think it's possible for partial application to use $ unless there's a token which is used to start off the partial application expression. The current partial application proposal does not have such a token.

js-choi commented 6 years ago

@littledan: I take it that, if we go down the Hack-style path, we're not trying for any kind of path for the placeholder to be subsumed by @rbuckton's partial application proposal, and therefore should avoid using the same token, is that right?

From what I could tell, syntactic partial application could use the same placeholder as Hack style iff syntactic partial application were forbidden in every placeholder-using pipe’s RHS. This could be a footgun—it creates a hidden context dependency between two very different results, which may cause the programmer to accidentally commit a mode error—but if we logically proceed anyway:

Proposal 2: Hack Style Only and Proposal 4: Smart Mix would forbid syntactic partial application in the RHS of all pipes—or, rather, the parser would always interpret the presence of a RHS placeholder as a pipe placeholder, not a partial-application placeholder. For instance, if |> is always a Hack pipe and ? is the placeholder for both |> and partial application, then f(?, 3) would be partial application, and x |> f(?, 3) would be f(x, 3).

Proposal 3: Split Mix would forbid syntactic partial application in the RHS of Hack pipes. It could also forbid it in the RHS of F-sharp pipes but it could also allow them. If |> is an F-sharp pipe, |: is a Hack pipe, and ? is the placeholder for both |: and partial application, then f(?, 3) would be partial application, x |> f(?, 3) would be f(?, 3)(x) (or it could be a syntax error), and x |: f(?, 3) would be f(x, 3).

If that analysis is correct, I’ll add it to the original post’s ? option. The problems of hidden contextual dependency—and of visual confusion with nullish coalescing and optional method chaining (assuming that syntactic partial application would stick with ?)—would remain.

ljharb commented 6 years ago

I would be very opposed to using any valid identifier - including $. It is a very common pattern to do var $ = document.querySelectorAll as well, for example - it’s not just about globals.

Shadowing bindings is fine when users explicitly choose the identifier - it would not be ok with me that a magic implicit binding would appear that shadows my code just for using an operator.

barneycarroll commented 6 years ago

I prefer personally ?, but I think it's worth unpacking 'visually confusing'. I think the statement that it is visually confusing in relation to the two other stage 1 proposals is misleading — those statements are more visually confusing with each other and with the ternary operator than anything else. Even if both of those get through, the ? placeholder proposal should not be held back on their account.

The ambiguity only creeps in when placeholders are nested in further expressions — @gilbert's original example being a placeholder in a ternary expression: ? ? : foo. This is the kind of scenario where the other two stage 1 operator proposals become problematic, when ?? can be read as either an optional chain on the placeholder.

It's a truism that nested ASCII operations are difficult to parse, but I think the placeholder is a special case inasmuch as it already bears the application-space cognitive weight of a deferred value within a special lexical scope of a higher order operation (the pipeline). So the situation only becomes complicated when we allow that the placeholder be used as an operand within a further expression nested inside a pipeline. Might it be worth outlawing that particular condition? — that is to say, a placeholder must be standalone, invocable only with ( or , either side of it?

In passing, I am firmly against the idea that an otherwise valid generic reference (like _ or $) be special cased. There is a special kind of semantic ambiguity introduced in scenarios like that of this in class arrow methods, when lexical parsing rules change based on higher order context. To do that with something which is otherwise up to user semantics is by all accounts a really imposing proposal (I foresee eslint rules to try and retro-ban them to compensate for this, invalidating previously legitimate and self-explanatory code).

stephaneraynaud commented 6 years ago

What about parameters with a name ? for example:

anArray
  |array> pickEveryN(array, 2)
  |array> array.filter(...)
  |filteredArray> makeQuery(filteredArray)
  |query> await readDB(query, config)
...

Then one could write something like this:

anArray
  |$> pickEveryN($, 2)
  |$> $.filter(...)
  |$> makeQuery($)
  |$> await readDB($, config)
...

I think this would improve code readability, as there may be a lot of transformations applied. If I want to read one particular line, I won't know what's passed to the function and what's for.

Other proposal, reuse arrow functions : [edit: actually, I noticed this is proposal 1]

anArray
  |> array => pickEveryN(array, 2)
  |> array => array.filter(...)
  |> filtered => makeQuery(filtered)
...

I like this proposal because it can be used with destructuring and stuff like this, while being readable.

There are probably a lot of issues with those proposals, but my main idea is that variables like "$" or "^^" lack of readability and are not really elegant (from my point of view).

mAAdhaTTah commented 6 years ago

Whichever token we choose is going have an effect on the placeholder syntax, either by producing two different placeholder syntaxes (which I'd prefer to avoid), by superseding the placeholder syntax (effectively killing it), or by forcing its hand (requiring it to use the same token). We should probably decide which approach we're taking and keep that in mind as we bikeshed the token for use in the pipeline.


@bisouduperou I think we ran into problems with a similar proposal for await, e.g. this:

x |$> pickEveryN($, 2)

could be parsed as:

x | ($ > pickEveryN($, 2))
charmander commented 6 years ago

Reusing arrow functions’ arrow works very well for most purposes, but not for await.

aikeru commented 6 years ago

Honestly I just really hope any form that has a placeholder variable of any shape or spelling gets adopted, because it adds tremendous power and flexibility to an operator that would otherwise be much more limited and constrained... Thanks for letting me add my 2c.

js-choi commented 6 years ago

In https://github.com/tc39/proposal-pipeline-operator/issues/84#issuecomment-363454642 I used a ## nullary operator as a pipe placeholder. It looks nice and it doesn’t mess up GitHub’s current JavaScript syntax highlighting, but it probably would be quite visually confusing with private fields, so I don’t actually think it’s a good idea, heh.

gilbert commented 6 years ago

Ok, if $ is too commonly used in user-land, then how about $$, like the actual Hack pipe operator?

mAAdhaTTah commented 6 years ago

@gilbert I was also thinking about $_ as another possibility.

stephaneraynaud commented 6 years ago

Let's try to not end up with smileys please $_$

js-choi commented 6 years ago

Ah, $_ brings back dormant memories of Perl…

For what it’s worth, Perl 6 actually turns Perl 5’s $_ into an impressively unified concept of a lexical “topic variable”, which may be lexically bound using a given block or a for block and which is implicitly used by many other types of statements, operators, and functions, making for rather pithy tacit code. Think of it like linguistic topics. And in general, Perl 6’s design (fun fact: they actually released 6.0 some time back) is worth checking out you want to dive into the heart of some ingeniously mad and madly ingenious PL design.

I am in no way suggesting that an implicit topic variable be a thing in JavaScript beyond Pipe Proposal 2/3/4, though it’s pretty fun to think about.

ljharb commented 6 years ago

@gilbert tbqh, i very strongly would object to any valid identifier there - it’s not just about “commonly used” for me, it’s about “ever used”.

gilbert commented 6 years ago

@ljharb I think such a strong stance to take would make sense if $$ were made globally available, but here it's only on the right-hand side of a pipeline – a very small scope, of which a programmer consciously introduces by writing |> in the first place.

ljharb commented 6 years ago

Magically introducing an implicit binding that shadows something defined in an outer scope is with-like behavior, and after we all worked so hard to remove with from strict mode, I’d think we’d be loath to reintroduce it.

gilbert commented 6 years ago

I agree it's implicit, but I would not equate to with. Yes we'd be loath to reintroduce with, but this is not remotely the same thing.

rbuckton commented 6 years ago

PowerShell also uses $_ as a topic variable in a number of places:

// pipes
Get-Files | ForEach-Object { Out-Host $_ };

// catch blocks
try { ... }
catch [System.Exception] {
  Out-Host $_.Exception.GetType().FullName; 
}

// filters/functions
function Foo {
  begin { ... }
  process { Out-Host $_; }
  end { ... }
}

Of course, that's because every variable in PowerShell is prefixed with $...

aikeru commented 6 years ago

Ah, $_ brings back dormant memories of Perl…

PowerShell also uses $_ as a topic variable in a number of places:

FWIW, Ruby uses this too. If JS were to adopt $_ as a topic variable or something like it, there's lots of precedent.

jridgewell commented 6 years ago

there's lots of precedent.

Node's also set precedent with _ being the last evaluated expression, but if it's defined in-scope it the variable you set it to.

js-choi commented 6 years ago

There is also Safari Web Inspector’s use of $1, $2, … to denote previously evaluated expressions in its console REPL, I suppose.

I used to be very against using a valid identifier for a pipe placeholder, but being reminded of Perl and Ruby made me realize that it might not be that weird. Then again, that there is an implicit binding at all in a Proposal-2,3,4 pipe is relatively unprecedented in ES. with was very bad especially because of its mucking up of static optimization, which Proposal-2,3,4 pipes do not have at all. But could using a valid identifier make static analysis of a pipe’s RHS—e.g., to determine whether there is no placeholder in the RHS—more difficult?

I plan to have my Babel plugin for Proposal 4 support configuration of what its placeholder is, to encourage experimentation (if its tokenization permits it). What its default placeholder should be, I don’t yet know. Maybe a non-ASCII placeholder by default might be interesting after all, haha.

stephaneraynaud commented 6 years ago

I don't think it's about weirdness but about origin. That you don't know about what an operator means is ok. You may don't know what "yield" or "await" means, because those are operators. But a valid identifier is, by default, a variable previously defined somewhere. By adding valid identifiers like "$_", you will need to ask yourself "am I in pipe ?" "does it come from pipe" "is it a global / simple variable?". I deeply encourage to avoid such (little) confusion.

While I personnally prefer meaningful placeholders ("$_" is as readable as "let thing = stuff()"), why not using @ as placeholder?

anArray
  |> pickEveryN(@, 2)
  |> @.filter(...)
  |> makeQuery(@)
  |> await readDB(@, config)
...
js-choi commented 6 years ago

@bisouduperou: I agree that too much context sensitivity is undesirable. I am not a big fan of shadowing $; I might want to use an outer $ in a pipeline’s RHS, although I suppose that I could always just reassign it to another variable. I’m gradually warming up to $ vis-à-vis Perl/Ruby, although at least one TC39 member has expressed strong disapproval of $ for reasons with which I agree.

In any case, @ is probably impossible as a pipe placeholder due to its use as a prefix by the stage-2 decorators proposal.

@rbuckton wrote a useful list of current operator uses in https://github.com/tc39/proposal-partial-application/issues/21#issuecomment-361092565. There are some ASCII characters here that have not yet been considered for pipe placeholders. ~~ particularly comes to mind as an option, although your mileage may vary with the flavor of ASCII soup it might bring. In any case, I’ll try to add ~~ to the original post and the wiki later today.

js-choi commented 6 years ago

In light of some possible confusion that has occurred around the phrase “Hack style” (Proposal 2 only versus Proposals 2,3,4), I’m renaming this issue. I may do the same in the wiki, hopefully in a way that doesn’t break previous anchor links.


There’s been quite a bit of discussion in #89 on the possible interactions between Proposals 2,3,4 and other proposals, particularly @rbuckton’s syntactic partial application (PA) and HOF operators. I’ll try to update the issue original post and wiki later today with points from the discussion.


[@littledan, #93 (comment)] I'd prefer if we can minimize the number of tokens we introduce to make the feature set easier to learn. From that perspective, the optimal solution would be one token for pipeline, and one token for partial application and/or pipeline placeholder.

[@zenparsing, #89 (comment 1), #89 (comment 2)]: Yep, partial application is a red herring with respect to pipelines.…I think [this quote] expressed the idea better than I could have:

Trying to explain pipelines (which are fundamentally unary) in terms of partial application (which are n-ary) seems to me to be a fundamental mismatch in their models.

Putting these here from other issues because they’re TC39-member opinions relevant to whether the pipe placeholder should have the same token as syntactic PA.


As far as priorities go, we should talk about whether readability is more important to optimize than writability, particularly now that ASCII operators have largely been exhausted. “Most code will be written once then read many times,” after all. In particular, non-ASCII Unicode syntax characters may be useful. A reserved keyword might also be worth considering, although perhaps not.

Let’s take a stark example of the writability/readability: a non-ASCII syntax character. may be more visually readable than the ASCII soup ~~, but the latter is far easier to input. optimizes for readability at the expense of writability; ~~ optimizes for writability perhaps at the expense of readability. To what extent the trade off is worth one way or the other is difficult to ascertain.

For what it’s worth, Perl 6, Julia, and Scala support and idiomatically use non-ASCII Unicode operators (there are also some amusing responses in a Reddit thread from 2016).

Of course, there is infamously also APL, which required encoding of numerous special operators in Unicode; its successor, the J language, eschews those non-ASCII operators in favor of ASCII digraphs—whether the resulting soup is readable enough to be worth it is up to you.

A long conversation over non-ASCII operators’ trade offs in Julia occurred in 2012. Julia’s REPL and IDE offer text “expansion” (contraction, rather) of LaTeX-style backspace-delimited abbreviations for non-ASCII characters, such as \dot for ·.

Perl 6 tries to accommodate both readability and writability by offering both non-ASCII Unicode operators and ASCII equivalents of the same operators, e.g., vs. !=: TIMTOADY / TIMTOWTDIBSCINABTE versus TOOWTDI. Perl 6 also offers advice on actually inputting Unicode characters in general.

There is also the precedent of FiraCode by @tonsky, a monospace font with numerous ligatures for improved visual display of many common operator spellings, and which sidesteps the writability tradeoff completely, in exchange for a one-time installation cost. Relatedly, the same author offers a clojure-unicode library for operators like λ, , etc., instead of fn, not=, ->, etc.—although in Clojure, being a Lisp, operators are literally the same as variable symbols.

Another aspect of non-ASCII is editor/IDE support for display, but it is already a fait accompli that ES supports non-ASCII variable names and Unicode characters in general. JavaScript’s application is the web, after all, as well as Node.js, both of which are already strongly coupled to Unicode.

Of course, all is this is moot if it is decided that $ is okay after all, although at least one TC39 member has above expressed strong disapproval of $.


In any case, I’ll try to update the issue’s and wiki’s list of possible placeholders sometime today with ~~, $_, $_$ (kidding), the from #89 for illustrative purposes, the elsewhere-suggested (?), and ? shared with PA. And whatever reserved keywords are available, I guess. private, anyone? I’m joking.

js-choi commented 6 years ago

These currently are the most topical (ha) bikeshedding questions that I see now:

  1. To what extent must the pipe placeholder visually resemble @rbuckton’s PA placeholder: not at all vs. visually similar vs. identical?

    Relatedly, how much should the pipe placeholder stay compatible with @rbuckton’s HOF operators, which possibly would use {…}?

  2. What is the optimal tradeoff in writability (easily typed ASCII soup, e.g., ~~, or easily typed privileged valid variable, e.g., $) versus readability (less easily inputted non-ASCII syntax, e.g., )?

  3. Related to question 2: Can non-ASCII Unicode syntax characters be considered for the pipe placeholder, or must they be categorically excluded?

    A list of all possible Pattern_Syntax Unicode characters is available.

  4. If question 3’s answer is that non-ASCII Unicode syntax may be excluded, which non-ASCII syntax character would be visually understandable and/or less difficult to input?

    Many non-ASCII symbols are easily inputted in certain OSes. For instance, in macOS, several dozen typographic characters are directly typable using Option or Option + Shift (image of keyboards with various active modifier keys via Macworld article. It may be worth determining if there is an intersection of these easily typable non-ASCII characters across the default keyboard layouts of many OSes.

  5. For nullary operators vs. valid variable identifiers: How important is it that the placeholder be statically analyzable?

    A nullary operator can be always be statically recognized in the RHS. In contrast, a valid identifier can be statically recognized only if the rule is: “Tacit function calling may occur only when the RHS is a bare identifier, rather than allowing the RHS to be any arbitrary expression without a placeholder.”

  6. Operator vs. identifier again: How often would someone want to use an identifier from an outer lexical context of the same name as the pipe placeholder?

    If the placeholder is $, how often would a programmer want to use JQuery’s $ or another externally defined $ in a pipe’s RHS, as well as the pipe placeholder? How often would they be surprised if they could not, without defining a dummy variable for the outer $? How bad of a footgun (i.e., bug by programmer-unexpected behavior) would this be?

    Note that shadowing does apply to both identifiers and operators for nested pipelines, e.g., … |> f(y => do { const x = ■; x |> ■ + x }) or perhaps … |> f(y => ■ |> ■ + x).

ljharb commented 6 years ago

To what extent the trade off is worth one way or the other is difficult to ascertain.

Although i think a non-ascii token is a nonstarter, i also think that code is read far, far more often than it is written, so i always prefer to optimize for readability over writability.

How often would someone want to use an identifier from an outer lexical context of the same name as the pipe placeholder?

If the answer isn’t “never”, then it’s precisely identical to “always”. Again, I will strenuously object to any advancement of this proposal if it magically and implicitly shadows any identifier (including any potential global identifier).

gilbert commented 6 years ago

If the answer isn’t “never”, then it’s precisely identical to “always”.

Can you explain why you take such an absolute stance? The pipeline operator is going to have some implicitness, whether F-sharp (invocation) or Hack style (binding). What makes the latter "magic" and not the former?

charmander commented 6 years ago

The pipeline operator is going to have some implicitness, whether F-sharp (invocation)

An operator with the sole purpose of calling its right operand with its left operand as an argument doing just that is about as explicit as it gets, no?

gilbert commented 6 years ago

I agree, and would say the same thing about Hack-style. Just as |> would be an explicit indicator of invocation, |> would be an explicit indicator of a scoped variable binding.

charmander commented 6 years ago

In any case, @ is probably impossible as a pipe placeholder due to its use as a prefix by the stage-2 decorators proposal.

Since decorators aren’t arbitrary expressions, I don’t think there’s a conflict. (With regard to readability: it’s unlikely for a decorator to be found in a pipeline.) It still doesn’t solve the relationship with the partial application proposal, though.

aikeru commented 6 years ago

If @ is problematic, was @@ already suggested as a placeholder?

ljharb commented 6 years ago

@charmander arg |> new @classDecorator class { constructor(...args) {} }

charmander commented 6 years ago

@ljharb new $ classDecorator doesn’t parse, so it’s unambiguous.

ljharb commented 6 years ago

@charmander I was replying to "it’s unlikely for a decorator to be found in a pipeline", illustrating why @ is indeed a conflict.

charmander commented 6 years ago

@ljharb So what you’re saying is that it is not unlikely to find this type of expression

arg |> new @classDecorator class { constructor(...args) {} }

in a pipeline? To the extent that someone would be likely to confuse the two uses of @? That was my point about readability – I don’t think anyone is going to mistake a placeholder use of @ as a decorator.

ljharb commented 6 years ago

I'm saying that it's possible, and that "likely" is entirely irrelevant.

charmander commented 6 years ago

@ljharb I disagree. There are plenty of confusing expressions that it’s possible to create in JavaScript. They’re not strong arguments against a given implementation by themselves.

ljharb commented 6 years ago

When we have the choice of something that would work for 100% of use cases (an unused token, and/or an invalid identifier), why would we settle for less than 100%?

charmander commented 6 years ago

@ljharb @ works in 100% of use cases. It would be a character with an overloaded meaning because of decorators; I was mentioning that the impact of the overloaded meaning doesn’t seem significant. Thanks to the private fields proposal, there is no ASCII candidate left without an overloaded meaning, so readability of typical expressions is quite relevant when exploring single-character non-identifier placeholders that can appear anywhere.

ljharb commented 6 years ago

If there's nothing left without an overloaded meaning that's a single token, then obviously a single token is unavailable - multiple tokens must be considered.

js-choi commented 6 years ago

I finally updated the issue’s original post. Possible tokens are now laid out in a table format. There is a column for opinions expressed by TC39 members with citations; I did my best, but if anyone feels that their opinion is misrepresented, please let me know and I’ll fix it very quickly. There are also now two new categories of tokens: prefixed keywords and called keywords, as inspired by syntactic PA’s ?this and temporary bindings’ const(…) respectively.

I’ll try to update the wiki with the same, sometime in the next days.

littledan commented 6 years ago

FWIW in the current decorators proposal, you can only decorate a class declaration, not a class expression.

rbuckton commented 6 years ago

FWIW in the current decorators proposal, you can only decorate a class declaration, not a class expression.

It will probably need to be in a future proposal then. We still get feedback regularly on TypeScript that we don't support decorators yet on class expressions or object literal members.

js-choi commented 6 years ago

Edited @ to note ambiguity only if class-decoration expressions become a thing, which does seem likely.

Added # as a possible placeholder. I’m becoming a fan of it; its use would usually be quite visually distinct from this.#x. See Freenode #tc39 2018-02-10:

\: I’m wondering if # might be an option for nullary pipe placeholder; visual noise aside, would it actually be syntactically ambiguous with .# private fields? After all, a pipe placeholder can never occur after a ..

\<+littledan> I don't think there's any syntactic ambiguity, but as far as intuition, I can see how people would want to avoid reusing # as it already has another meaning

of course, so does ?, so that's not really a tiebreaker

even if we adopt wycats's private shorthand syntax, there would still not be any ambiguity since that has to be followed by an IdentifierName