documentation improvements
This commit is contained in:
parent
dbc5048a9a
commit
62643fbc93
3 changed files with 45 additions and 2 deletions
|
|
@ -1885,7 +1885,7 @@ Overloading of the subscript operator
|
||||||
|
|
||||||
The ``[]`` subscript operator for arrays/openarrays/sequences can be overloaded.
|
The ``[]`` subscript operator for arrays/openarrays/sequences can be overloaded.
|
||||||
Overloading support is only possible if the first parameter has no type that
|
Overloading support is only possible if the first parameter has no type that
|
||||||
already supports the built-in ``[]`` notation. Currently the compiler currently
|
already supports the built-in ``[]`` notation. Currently the compiler
|
||||||
does not check this. XXX Multiple indexes
|
does not check this. XXX Multiple indexes
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,49 @@ encloses the header file in ``""`` in the generated C code.
|
||||||
|
|
||||||
**Note**: This will not work for the LLVM backend.
|
**Note**: This will not work for the LLVM backend.
|
||||||
|
|
||||||
|
|
||||||
|
Compile pragma
|
||||||
|
--------------
|
||||||
|
The `compile`:idx: pragma can be used to compile and link a C/C++ source file
|
||||||
|
with the project:
|
||||||
|
|
||||||
|
.. code-block:: Nimrod
|
||||||
|
{.compile: "myfile.cpp".}
|
||||||
|
|
||||||
|
**Note**: Nimrod computes a CRC checksum and only recompiles the file if it
|
||||||
|
has changed. You can use the ``-f`` command line option to force recompilation
|
||||||
|
of the file.
|
||||||
|
|
||||||
|
|
||||||
|
Link pragma
|
||||||
|
-----------
|
||||||
|
The `link`:idx: pragma can be used to link an additional file with the project:
|
||||||
|
|
||||||
|
.. code-block:: Nimrod
|
||||||
|
{.link: "myfile.o".}
|
||||||
|
|
||||||
|
|
||||||
|
Emit pragma
|
||||||
|
-----------
|
||||||
|
The `emit`:idx: pragma can be used to directly affect the output of the
|
||||||
|
compiler's code generator. So it makes your code unportable to other code
|
||||||
|
generators/backends. Its usage is highly discouraged! However, it can be
|
||||||
|
extremely useful for interfacing with C++ or Objective C code.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
.. code-block:: Nimrod
|
||||||
|
{.emit: """
|
||||||
|
static int cvariable = 420;
|
||||||
|
""".}
|
||||||
|
|
||||||
|
proc embedsC() {.pure.} =
|
||||||
|
var nimrodVar = 89
|
||||||
|
# use backticks to access Nimrod symbols within an emit section:
|
||||||
|
{.emit: """fprintf(stdout, "%d\n", cvariable + (int)`nimrodVar`);""".}
|
||||||
|
|
||||||
|
embedsC()
|
||||||
|
|
||||||
|
|
||||||
LineDir option
|
LineDir option
|
||||||
--------------
|
--------------
|
||||||
|
|
|
||||||
2
todo.txt
2
todo.txt
|
|
@ -1,6 +1,6 @@
|
||||||
- we need a way to disable tests
|
- we need a way to disable tests
|
||||||
- {.extern: "thisfile.m".} pragma for objective C/C++ support
|
- {.extern: "thisfile.m".} pragma for objective C/C++ support
|
||||||
- deprecate ^ and make it awailable as operator
|
- deprecate ^ and make it available as operator
|
||||||
|
|
||||||
|
|
||||||
High priority (version 0.9.0)
|
High priority (version 0.9.0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue