|
I really liked the idea of "method(action : "getObject"): CustomType;". Looks better.
Anyway, regarding Peter's suggestion, I don't think parsing variables would be a good idea, it would really complicate for the compiler, as the string could be the return of a function, etc. The idea is just to support existing code that use this pattern,
so we can have code completion for everything correctly.
As for the default overload, after giving it some thought, I believe it is a good idea. Looking at this:
interface Foo {
method("bar") : bool;
}
class X implements Foo {
method(arg : string) : bool { ... }
}
It looks a little bit strange without the default overload. Also, if you don't have it, would require the compiler to throw an error if the string doesn't match, and that would open the door for other parameter value checks, people would use it for strings
and ask why it is not available for integers... better to keep it simple.
The following rules could be applied:
- The value can only be a string literal
- Only interfaces would be allowed to have this kind of signature
- Must have a default overload without the values
- Literal parameters must be the firtst parameters, never in the middle or in the end (opposite rule of optional parameters)
As for the speed, I don't think would make much difference if made only for strings and not all literals.
|