Category:Jsish: Difference between revisions
Content added Content deleted
m (version update to 2.8) |
m (spacing and some prose change) |
||
Line 21: | Line 21: | ||
* Function definitions can use type specifiers and default values. |
* Function definitions can use type specifiers and default values. |
||
While '''Jsish''' can honestly be called a Javascript interpreter, the extensions and differences from standard, form what is, realistically, a different language. |
While '''Jsish''' can honestly be called a Javascript interpreter, the extensions and differences from standard, form what is, realistically, a different language. For instance: |
||
nodejs> [1,2] + [2,1] |
nodejs> [1,2] + [2,1] |
||
"1,22,1" |
"1,22,1" |
||
jsish |
jsish# [1,2] + [2,1]; |
||
0 |
0 |
||
Typed parameters for functions also sets Jsi apart from other ECMAScript implementations. |
|||
prompt$ jsish |
prompt$ jsish |
||
Line 33: | Line 36: | ||
# function foo (a:number, b:string="ok"):number { return a+1; } |
# function foo (a:number, b:string="ok"):number { return a+1; } |
||
variable |
variable |
||
/* Demonstrate parameterized types */ |
/* Demonstrate parameterized types */ |
||
# foo('a', 1, 2) |
# foo('a', 1, 2); |
||
warn: got 3 args, expected 1-2, calling function foo(a:number, b="ok"):number (at or near "a") |
warn: got 3 args, expected 1-2, calling function foo(a:number, b="ok"):number (at or near "a") |
||
warn: type mismatch for argument arg 1 'a': expected "number" but got "string", in call to 'foo' <a>. (at or near "a") |
warn: type mismatch for argument arg 1 'a': expected "number" but got "string", in call to 'foo' <a>. (at or near "a") |
||
Line 41: | Line 44: | ||
warn: type mismatch returned from 'foo': expected "number" but got "string", in call to 'foo' <a1>. (at or near "a") |
warn: type mismatch returned from 'foo': expected "number" but got "string", in call to 'foo' <a1>. (at or near "a") |
||
"a1" |
"a1" |
||
# foo(1) |
# foo(1); |
||
2 |
2 |
||
# |
# |