Consider javascript already support for default parameters, so maybe we can use the default parameter to specify the strong type.
What about non-default parameters?
What if I have an "int64" function already defined? Will this skip over my
int64 function? What about a = something(0)
- will that call my
"something" function, whereas "int64" is special and skipped over?
Don't you just mean:
function addWithType(a=0, b=0) {
return int64(a) + int64(b);
}
I like to use what the language already have so if we can denote the type by constructor:
Function foo(a=Number(64),b=String()){ return b+a; }
Sent from my iPhone
How do you distinguish between function f(a = defaultComesFromEvaluatingSomeFunction(true))
from function f(a = StrongType(true))
?
It’s ambiguous which one is meant, and that doesn’t really work.
If strong type is needed, why not use TypeScript?
Well, native support means better performance for browsers.
2015-05-20 17:02 GMT+08:00 Gary Guo <nbdd0121 at hotmail.com>:
For example:
function addWithType(a = int64(0), b = int64(0)) { return a + b; }
This function is input add two int64 and return a int64