cicada-lang / cicada-plct

Cicada Language (PLCT little team)
https://cicada-lang.org
GNU General Public License v3.0
91 stars 7 forks source link

[design] nullary class application #24

Open xieyuheng opened 2 years ago

xieyuheng commented 2 years ago

Problem:

In js/ts there are new User() and new User.

How should we handle nullary applications?

xieyuheng commented 2 years ago

Solution 1:

Do not support nullary class application.

Because from the following example, we see that, new ABC() is only useful when all properties are fulfilled.

class ABC {
  a: String = "a"
  b: String = "b"
  c: String = "c"
}

check new ABC(): ABC

But in this case, we can simply use object:

let abc = {
  a: "a",
  b: "b",
  c: "c",
}