summary refs log tree commit diff stats
path: root/doc/tut2.txt
diff options
context:
space:
mode:
authorYuriy Glukhov <yglukhov@users.noreply.github.com>2015-12-09 22:32:58 +0200
committerYuriy Glukhov <yglukhov@users.noreply.github.com>2015-12-09 22:32:58 +0200
commitbf874cff90b78078470b35a4e9b23c45735dbe4b (patch)
tree56240b97e5d460984093a34f46b6d103f5d0ecad /doc/tut2.txt
parent6b3b7eef8fffbf67996b23f5c582d544275186ec (diff)
downloadNim-bf874cff90b78078470b35a4e9b23c45735dbe4b.tar.gz
Added a few notes regarding JavaScript
Diffstat (limited to 'doc/tut2.txt')
-rw-r--r--doc/tut2.txt14
1 files changed, 14 insertions, 0 deletions
diff --git a/doc/tut2.txt b/doc/tut2.txt
index db9e4cd58..7479d8479 100644
--- a/doc/tut2.txt
+++ b/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
 using the ``dumpTree`` macro, but of course you can call that at any point of
 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.