Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Feb 19, 2018. It is now read-only.
/discussPublic archive
This repository was archived by the owner on Feb 19, 2018. It is now read-only.

CS2 Discussion: Features: const assignment operator #31

Closed
@GeoffreyBooth

Description

@GeoffreyBooth

Branching off from#1 and#30, I thought it would be good to have a thread dedicated to discussing the proposed new operator for explicitly declaring and assigning a variable as aconst. This thread isnot for debating automaticlet assignment, or whether we should change other things related to variable assignment. Justconst. For other topics, please comment on other issue threads.

The consensus from#1 seems to be to add an:= operator that works like=, but declares and assigns a variable as aconst. So:

foo :=42

becomes:

constfoo=42;

This has the advantage that it’s not a breaking change; currently:= fails to compile. There is no need to support?:=, since by definition constants can’t be reassigned.

Nothing else would be changed by adding this new operator. Normal assignment is handled as it is today, withvar. Even though using:= would causeconst to be in the generated output, this feature is “opt in” like modules and the same warning would apply about transpiling CoffeeScript’s output.

If people like the idea but disagree with the syntax, I invite you to propose an alternate syntaxthat isn’t a breaking change. Simply following ES2015, with a syntax likeconst foo = 42, is an option sinceconst is already a reserved word in CoffeeScript.

So I think the debate is: should we add this at all? And if so, this syntax or some other backwards-compatible syntax?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp