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

class #16

Closed
Tracked by #1
slofp opened this issue Dec 28, 2023 · 0 comments
Closed
Tracked by #1

class #16

slofp opened this issue Dec 28, 2023 · 0 comments
Labels
project/Lib Ai.js main source issue

Comments

@slofp
Copy link
Owner

slofp commented Dec 28, 2023

以下の変換を予定

class A {
  constructor(z) {
    this.mem = z * 10;
  }
  static a() {
  }
  b() {
  }
  static c = 0;
  d = 0;
  static #aa() {
  }
  #bb() {
  }
  static #cc = 0;
  #dd = 0;
}
new A(10);

変換後

let A = {
  new: @(z) {
    let this = {}

    // define method
    this.b = @() {}
    this.__bb = @() {}

    // inited property
    this.d = 0
    this.__dd = 0

    // constructor
    this.mem = z * 10

    this
  },
  // static method
  a: @() {},
  __aa: @() {},
  // static property
  c: 0,
  __cc: 0
}

A.new(10)

これに対する成約

  • extendsは使用できない -> マージ処理をすればできなくはないが大変
  • public identifierに対する__から始まる名前は使用不可 -> privateとの区別をするため
  • get, setは定義不可 -> 実装が大変
@slofp slofp added the project/Lib Ai.js main source issue label Dec 28, 2023
@slofp slofp mentioned this issue Jan 14, 2024
@slofp slofp closed this as completed Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
project/Lib Ai.js main source issue
Projects
None yet
Development

No branches or pull requests

1 participant