Skip to content
This repository has been archived by the owner on Feb 19, 2018. It is now read-only.

CS2 Discussion: Features: Static keyword #70

Closed
GeoffreyBooth opened this issue Jan 27, 2017 · 4 comments
Closed

CS2 Discussion: Features: Static keyword #70

GeoffreyBooth opened this issue Jan 27, 2017 · 4 comments

Comments

@GeoffreyBooth
Copy link
Collaborator

GeoffreyBooth commented Jan 27, 2017

CoffeeScript classes already have support for static methods, via @methodName syntax:

class Maths
  @square: (x) -> x * x

Assuming we implement getters and setters, and assuming their syntax looks something like this:

class Square extends Rectangle
  get perimeter: -> @side * 4
  set area: (x) -> @side = Math.sqrt x

Then I think we should also support the static keyword, for consistency:

class Maths
  static square: (x) -> x * x

Please keep discussion of get and set over in #17. If we decide not to implement get and set, or if we implement them in some syntax unlike what’s here, then we don’t need the static keyword. I propose we add the static keyword only if we add get and set keywords. We would also keep the @methodName syntax, for backward compatibility.

@mrmowgli
Copy link

I actually would like to avoid adding an alternate keyword for this. I think current way of dealing with it is consistent with the language. I can see some confusion around this, but for the most part that falls back to adding to the documentation.

@mrmowgli
Copy link

Also it looks like we are avoiding adding get/set to the language.

@GeoffreyBooth
Copy link
Collaborator Author

Closing per consensus in #17

@coffeescriptbot coffeescriptbot changed the title Static CS2 Discussion: Features: Static keyword Feb 19, 2018
@coffeescriptbot
Copy link
Collaborator

Migrated to jashkenas/coffeescript#4963

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

No branches or pull requests

3 participants