Anonymous user
Category:Jsish: Difference between revisions
Highlight some more of the Jsi feature set
(return inside try/catch is now supported) |
(Highlight some more of the Jsi feature set) |
||
Line 16:
* The Error object is not implemented: the argument to '''catch()''' is a string.
* The Date object is not implemented: '''strftime/strptime''' are provided to replace the functionality.
* UTF character manipulation is not yet supported, but ''whole string'' literals are.
* The '''typeof []''' is "array" instead of "object".
* Function definitions can use type specifiers and provide default values.
Line 33:
prompt$ jsish
Jsish interactive: see 'help [cmd]'
# function foo (a:number, b:string="ok"):number { puts(b); return a+1; }
variable
/* Demonstrate
# foo('a', 1, 2);
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 2 'b': expected "string" but got "number", in call to 'foo' <1>. (at or near "a")
1
warn: type mismatch returned from 'foo': expected "number" but got "string", in call to 'foo' <a1>. (at or near "a")
"a1"
# foo(1);
ok
2
#
The '''jsish''' executable evaluates scripts by interpreter directive or from files given as command line arguments.▼
▲The '''jsish''' executable evaluates scripts by interpreter directive
Unit testing is built into the interpreter, assisted by Jsi syntax allowing for type specifiers, and with '''=!EXPECTSTART!=''', '''=!EXPECTEND!=''' source code markers inside comments (along with =!INPUTSTART/END!= pairs) used for validation during test run capture. Unit test mode is initiated when '''jsish''' is invoked with a '''-u''' command line option.▼
▲Unit testing is built into the interpreter, assisted by Jsi syntax allowing for argument and return type specifiers, and with special '''=!EXPECTSTART!=''', '''=!EXPECTEND!=''' source code markers inside
For example:
Line 84 ⟶ 87:
[PASS] sampler.jsi</pre>
''The operating system interpreter directive in
Modules and packaging ('''provide''' and '''require''') is also part and parcel of Jsi development. Command option parsing, autoloading, versioning and builtin help is included in the Jsi module design along with other programmer and user friendly features.
Embedding Jsi in C or C++ applications
Jsish includes database and websocket modules; SQLite, MySQL, libwebsockets. The interpreter also includes Zlib compressed Virtual File System features; support modules are included in an archive appended to the executable and mounted as '/zvfs/'. Deployment of entire applications can ship as a single file, including images and other normally external resources.
Jsish first appeared in 2015.
* https://jsish.org
|