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

ES 2017 #private class fields #5282

Closed
MegaJSDeveloper opened this issue Dec 30, 2019 · 1 comment
Closed

ES 2017 #private class fields #5282

MegaJSDeveloper opened this issue Dec 30, 2019 · 1 comment

Comments

@MegaJSDeveloper
Copy link

MegaJSDeveloper commented Dec 30, 2019

@GeoffreyBooth sayd: #4552 (comment)

Obviously we need to choose a different syntax than # to denote “private.” Maybe whoever wants to work on that can start a new issue with a proposal? And a PR can follow.

I create a new issue with a proposal:

coffeescript ~name is like javascript #name

private:
@~name
@.~name
this.~name

public:
@name
@.name
this.name

Wherever we can write obj.~prop we can write obj~prop, its both compile to obj.#prop

Example:

CoffeeScript:

class Cat
  
  constructor: ->
    @~name = 33
    return
    
  say: ->
    return @~name

Must compile to:

class Cat {
  #name
	
  constructor(){
    this.#name = 33
  }
	
  say(){
    return this.#name
  }

}

Private methods:

class Cat
    
  ~privateMethod: ->
    
  @~privateStaticMethod: ->

must compile to:

class Cat {

  #privateMethod(){ }
	
  static #privateStaticMethod(){ }

}

Access to another object:

class Point

  constructor: ->
    @~x = 0
    @~y = 0
    return
  
  
  equals: (point)->
    return @~x is point~x and @~y is point~y

Destructuring params to private vars:

class Point

  constructor: ({@~x,@~y})->
    return

  # or short syntax
  constructor: ({~x, ~y})->
    return

Ugly but not the CoffeeScript 3.0

@GeoffreyBooth
Copy link
Collaborator

Please stop opening issues in this repo. You’ve been banned several times and I would prefer not to keep contacting GitHub support for assistance.

Repository owner locked as spam and limited conversation to collaborators Dec 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants