Skip to content
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

Use () instead of void #10

Closed
ByteEater-pl opened this issue Jun 3, 2024 · 9 comments
Closed

Use () instead of void #10

ByteEater-pl opened this issue Jun 3, 2024 · 9 comments

Comments

@ByteEater-pl
Copy link

If void and _ are both problematic, and no single character alternative reaches consensus, perhaps () would work? The case using () = needs a lookahead for = in order to distinguish from CallExpression, but it seems much less quirky than what the two main contenders would require so far.

@rbuckton
Copy link
Collaborator

rbuckton commented Jun 3, 2024

Since using is not a reserved word, using () = x would be ambiguous with an Extractor.

@ByteEater-pl
Copy link
Author

Indeed, that's going to be the syntax for extractors. Since using is already a contextual keyword, it could be special cased – e.g. either completely prohibited as an extractor or just in the only ambiguous context that comes to my mind, i.e. without const, let or var, a top-level assignment (not nested). If the latter is preferred, the assignment could be easily achieved by parenthesizing, thus: (using() = expression).

@ljharb
Copy link
Member

ljharb commented Jun 3, 2024

Empty parens reads like a bug to me - this would be a very confusing syntax choice.

@ByteEater-pl
Copy link
Author

@ljharb, your opinion, disagreeing with mine, is likely to have more clout, so let me add some arguments. Empty parentheses are already used to denote empty ArrowParameters. And in a number of other languages they denote the unit value or unit type (or even both, in Haskell), or some empty structure.

But if it won't fly, then maybe 0 (unless it's going to be allowed in target positions, like it already is for specifying property names in object literals, e.g. {2: 3})? It means pure virtual in C++ (admittedly a remote analogy), so there's also precedent for giving it special meaning outside number literals. (And, even more remotely, GOTO 0 and RESUME 0 in some dialects of BASIC.)

@rbuckton
Copy link
Collaborator

rbuckton commented Jun 3, 2024

0 is not an option as it would conflict with pattern matching. This syntax must be valid for both destructuring, assignment, and pattern matching to be viable.

@rbuckton
Copy link
Collaborator

rbuckton commented Jun 3, 2024

If we are unable to use _, then void will likely work just fine. The only major concern I've seen was related to the cover grammar, which I believe I have solved in #9.

@gamebox
Copy link

gamebox commented Jun 15, 2024

As I've said elsewhere, I think the simple fact that void is four letters will severely hamper its uptake as many developers will find it less convenient and not understand any issues with just binding the value to a much shorter identifier.

@rbuckton
Copy link
Collaborator

As I've said elsewhere, I think the simple fact that void is four letters will severely hamper its uptake as many developers will find it less convenient and not understand any issues with just binding the value to a much shorter identifier.

That is a different topic than using (). See #11 about the potential to use identifiers.

@rbuckton
Copy link
Collaborator

As () is not a viable option, I am closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants