mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
Tweeks in the manual (#6599)
This commit is contained in:
@@ -206,7 +206,7 @@ strings, because they are precompiled.
|
||||
**Note**: Passing variables to the ``dynlib`` pragma will fail at runtime
|
||||
because of order of initialization problems.
|
||||
|
||||
**Note**: A ``dynlib`` import can be overriden with
|
||||
**Note**: A ``dynlib`` import can be overridden with
|
||||
the ``--dynlibOverride:name`` command line option. The Compiler User Guide
|
||||
contains further information.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ Guards and locks
|
||||
================
|
||||
|
||||
Apart from ``spawn`` and ``parallel`` Nim also provides all the common low level
|
||||
concurrency mechanisms like locks, atomic intristics or condition variables.
|
||||
concurrency mechanisms like locks, atomic intrinsics or condition variables.
|
||||
|
||||
Nim significantly improves on the safety of these features via additional
|
||||
pragmas:
|
||||
|
||||
@@ -105,7 +105,7 @@ From import statement
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
After the ``from`` statement a module name follows followed by
|
||||
an ``import`` to list the symbols one likes to use without explict
|
||||
an ``import`` to list the symbols one likes to use without explicit
|
||||
full qualification:
|
||||
|
||||
.. code-block:: nim
|
||||
@@ -123,7 +123,7 @@ in ``module``.
|
||||
Export statement
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
An ``export`` statement can be used for symbol fowarding so that client
|
||||
An ``export`` statement can be used for symbol forwarding so that client
|
||||
modules don't need to import a module's dependencies:
|
||||
|
||||
.. code-block:: nim
|
||||
|
||||
@@ -70,7 +70,7 @@ compileTime pragma
|
||||
The ``compileTime`` pragma is used to mark a proc or variable to be used at
|
||||
compile time only. No code will be generated for it. Compile time procs are
|
||||
useful as helpers for macros. Since version 0.12.0 of the language, a proc
|
||||
that uses ``system.NimNode`` within its parameter types is implictly declared
|
||||
that uses ``system.NimNode`` within its parameter types is implicitly declared
|
||||
``compileTime``:
|
||||
|
||||
.. code-block:: nim
|
||||
@@ -733,7 +733,8 @@ about the ``importcpp`` pragma pattern language. It is not necessary
|
||||
to know all the details described here.
|
||||
|
||||
|
||||
Similar to the `importc pragma for C <manual.html#importc-pragma>`_, the
|
||||
Similar to the `importc pragma for C
|
||||
<#foreign-function-interface-importc-pragma>`_, the
|
||||
``importcpp`` pragma can be used to import `C++`:idx: methods or C++ symbols
|
||||
in general. The generated code then uses the C++ method calling
|
||||
syntax: ``obj->method(arg)``. In combination with the ``header`` and ``emit``
|
||||
@@ -955,10 +956,11 @@ Produces:
|
||||
|
||||
ImportObjC pragma
|
||||
-----------------
|
||||
Similar to the `importc pragma for C <manual.html#importc-pragma>`_, the
|
||||
``importobjc`` pragma can be used to import `Objective C`:idx: methods. The
|
||||
generated code then uses the Objective C method calling syntax: ``[obj method
|
||||
param1: arg]``. In addition with the ``header`` and ``emit`` pragmas this
|
||||
Similar to the `importc pragma for C
|
||||
<#foreign-function-interface-importc-pragma>`_, the ``importobjc`` pragma can
|
||||
be used to import `Objective C`:idx: methods. The generated code then uses the
|
||||
Objective C method calling syntax: ``[obj method param1: arg]``.
|
||||
In addition with the ``header`` and ``emit`` pragmas this
|
||||
allows *sloppy* interfacing with libraries written in Objective C:
|
||||
|
||||
.. code-block:: Nim
|
||||
|
||||
@@ -142,10 +142,11 @@ The method call syntax conflicts with explicit generic instantiations:
|
||||
parsed as ``(x.p)[T]``.
|
||||
|
||||
**Future directions**: ``p[.T.]`` might be introduced as an alternative syntax
|
||||
to pass explict types to a generic and then ``x.p[.T.]`` can be parsed as
|
||||
to pass explicit types to a generic and then ``x.p[.T.]`` can be parsed as
|
||||
``x.(p[.T.])``.
|
||||
|
||||
See also: `Limitations of the method call syntax`_.
|
||||
See also: `Limitations of the method call syntax
|
||||
<#templates-limitations-of-the-method-call-syntax>`_.
|
||||
|
||||
|
||||
Properties
|
||||
@@ -178,7 +179,7 @@ different; for this a special setter syntax is needed:
|
||||
Command invocation syntax
|
||||
-------------------------
|
||||
|
||||
Routines can be invoked without the ``()`` if the call is syntatically
|
||||
Routines can be invoked without the ``()`` if the call is syntactically
|
||||
a statement. This command invocation syntax also works for
|
||||
expressions, but then only a single argument may follow. This restriction
|
||||
means ``echo f 1, f 2`` is parsed as ``echo(f(1), f(2))`` and not as
|
||||
|
||||
@@ -293,7 +293,7 @@ Limitations of the method call syntax
|
||||
|
||||
The expression ``x`` in ``x.f`` needs to be semantically checked (that means
|
||||
symbol lookup and type checking) before it can be decided that it needs to be
|
||||
rewritten to ``f(x)``. Therefore the dot syntax has some limiations when it
|
||||
rewritten to ``f(x)``. Therefore the dot syntax has some limitations when it
|
||||
is used to invoke templates/macros:
|
||||
|
||||
.. code-block:: nim
|
||||
|
||||
@@ -5,7 +5,7 @@ To enable thread support the ``--threads:on`` command line switch needs to
|
||||
be used. The ``system`` module then contains several threading primitives.
|
||||
See the `threads <threads.html>`_ and `channels <channels.html>`_ modules
|
||||
for the low level thread API. There are also high level parallelism constructs
|
||||
available. See `spawn`_ for further details.
|
||||
available. See `spawn <#parallel-spawn>`_ for further details.
|
||||
|
||||
Nim's memory model for threads is quite different than that of other common
|
||||
programming languages (C, Pascal, Java): Each thread has its own (garbage
|
||||
|
||||
@@ -7,12 +7,12 @@ There are 3 operations that are bound to a type:
|
||||
2. Destruction
|
||||
3. Deep copying for communication between threads
|
||||
|
||||
These operations can be *overriden* instead of *overloaded*. This means the
|
||||
These operations can be *overridden* instead of *overloaded*. This means the
|
||||
implementation is automatically lifted to structured types. For instance if type
|
||||
``T`` has an overriden assignment operator ``=`` this operator is also used
|
||||
``T`` has an overridden assignment operator ``=`` this operator is also used
|
||||
for assignments of the type ``seq[T]``. Since these operations are bound to a
|
||||
type they have to be bound to a nominal type for reasons of simplicity of
|
||||
implementation: This means an overriden ``deepCopy`` for ``ref T`` is really
|
||||
implementation: This means an overridden ``deepCopy`` for ``ref T`` is really
|
||||
bound to ``T`` and not to ``ref T``. This also means that one cannot override
|
||||
``deepCopy`` for both ``ptr T`` and ``ref T`` at the same time; instead a
|
||||
helper distinct or object type has to be used for one pointer type.
|
||||
|
||||
@@ -491,4 +491,4 @@ metatypes ``typed`` and ``typedesc`` are not lazy.
|
||||
Varargs matching
|
||||
----------------
|
||||
|
||||
See `Varargs`_.
|
||||
See `Varargs <#types-varargs>`_.
|
||||
|
||||
@@ -114,7 +114,8 @@ if the literal's value fits this smaller type and such a conversion is less
|
||||
expensive than other implicit conversions, so ``myInt16 + 34`` produces
|
||||
an ``int16`` result.
|
||||
|
||||
For further details, see `Convertible relation`_.
|
||||
For further details, see `Convertible relation
|
||||
<#type-relations-convertible-relation>`_.
|
||||
|
||||
|
||||
Subrange types
|
||||
|
||||
Reference in New Issue
Block a user