Hi, in javascript/typescript, we always define some functions or methods which have different behaviors depends on arguments, etc.:
export default class SName {
public equalsTo(name: string): boolean;
public equalsTo(name: SName): boolean;
public equalsTo(name: string | SName): boolean {
if (isSName(name)) {
return this._index === name._index;
}
if (!SName.TABLE[name]) {
return false;
}
return SName.TABLE[name] === this._index;
}
}
This feature is named 'overloading' in some languages and it in javascript is more flexible, but as we known, rust does not support it, so can we use macro to implement it ? Maybe it can like this:
With features 'overloading', 'optional arguments'(#1129) and 'getter/setter' (#222 ), we can built more powerful and flexible systems, and these features can just be implemented in javascript files and d.ts files. In current time, I can write my own js and ts files to do these, but an automatic implementation is awesome !
Thanks for the report! Would it be possible to define these preflight checks in Rust itself? That way you could take something like a &JsValue and then inspect it to figure out which implementation to delegate to?
Hi, in javascript/typescript, we always define some functions or methods which have different behaviors depends on arguments, etc.:
This feature is named 'overloading' in some languages and it in javascript is more flexible, but as we known, rust does not support it, so can we use macro to implement it ? Maybe it can like this:
to:
With features 'overloading', 'optional arguments'(#1129) and 'getter/setter' (#222 ), we can built more powerful and flexible systems, and these features can just be implemented in javascript files and d.ts files. In current time, I can write my own js and ts files to do these, but an automatic implementation is awesome !
Thanks !