Merge pull request #3638 from yglukhov/patch-2
Added a few notes regarding JavaScript
This commit is contained in:
commit
1a73cef765
1 changed files with 14 additions and 0 deletions
14
doc/tut2.txt
14
doc/tut2.txt
|
|
@ -990,3 +990,17 @@ generated by `treeRepr <macros.html#treeRepr>`_. If at the end of the this
|
||||||
example you add ``echo treeRepr(result)`` you should get the same output as
|
example you add ``echo treeRepr(result)`` you should get the same output as
|
||||||
using the ``dumpTree`` macro, but of course you can call that at any point of
|
using the ``dumpTree`` macro, but of course you can call that at any point of
|
||||||
the macro where you might be having troubles.
|
the macro where you might be having troubles.
|
||||||
|
|
||||||
|
|
||||||
|
Compilation to JavaScript
|
||||||
|
=========================
|
||||||
|
|
||||||
|
Nim code can be compiled to JavaScript. However in order to write
|
||||||
|
JavaScript-compatible code you should remember the following:
|
||||||
|
- ``addr`` and ``ptr`` have slightly different semantic meaning in JavaScript.
|
||||||
|
It is recommended to avoid those if you're not sure how they are translated
|
||||||
|
to JavaScript.
|
||||||
|
- ``cast[T](x)`` in JavaScript is translated to ``(x)``.
|
||||||
|
- ``cstring`` in JavaScript means JavaScript string. It is a good practice to
|
||||||
|
use ``cstring`` only when it is semantically appropriate. E.g. don't use
|
||||||
|
``cstring`` as a binary data buffer.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue