While it's nice the way various syntactic forms come together to produce an easily readable prototype definition without the need for special syntax, we could still stand to gain some by adding special syntax.
proto Manager like Employee {
@employees = [ ];
fn init() :{
super();
}
fn addEmployee(employee) :{
this.@employees.push(employee);
}
}
Pros
We could remove the way symbols mix into an object by default (transferability). foo := bar currently mixes all bar's symbol properties into foo (except for symbols explicitly declared as non-transferable). Although this could be nice in some cases, it has never quite sat well with me and could represent a leak of private data.
We'd have the freedom to enforce modules to only use declarative forms in the top level. This isn't currently possible because it would be common to want to export a prototype and building prototypes currently requires runtime code. Restricting module level code to declarative forms could have some benefits regarding export/import syntax and semantics, static analysis, and circular dependency management. We may not necessarily want to use this restriction or all of the possible benefits, but it at least opens up these possibilities.
Proposal
Currently prototypes are declared by stating a base class and mixing in properties.
While it's nice the way various syntactic forms come together to produce an easily readable prototype definition without the need for special syntax, we could still stand to gain some by adding special syntax.
Pros
foo := bar
currently mixes allbar
's symbol properties intofoo
(except for symbols explicitly declared as non-transferable). Although this could be nice in some cases, it has never quite sat well with me and could represent a leak of private data.