Merge branch 'devel' into araq

This commit is contained in:
Andreas Rumpf 2017-09-15 09:27:51 +02:00
commit 39f0195ebf
334 changed files with 4636 additions and 2763 deletions

View file

@ -65,7 +65,7 @@ Advanced options:
--skipUserCfg do not read the user's configuration file
--skipParentCfg do not read the parent dirs' configuration files
--skipProjCfg do not read the project's configuration file
--gc:refc|v2|markAndSweep|boehm|go|none
--gc:refc|v2|markAndSweep|boehm|go|none|regions
select the GC to use; default is 'refc'
--index:on|off turn index file generation on|off
--putenv:key=value set an environment variable

View file

@ -539,9 +539,6 @@ Network Programming and Internet Protocols
* `joyent_http_parser <joyent_http_parser.html>`_
Wrapper for the joyent's high-performance HTTP parser.
* `libcurl <libcurl.html>`_
Wrapper for the libcurl library.
* `openssl <openssl.html>`_
Wrapper for OpenSSL.

View file

@ -132,7 +132,7 @@ translated into a C array of undetermined size:
.. code-block:: nim
type
ArrayPart{.unchecked.} = array[0..0, int]
ArrayPart{.unchecked.} = array[0, int]
MySeq = object
len, cap: int
data: ArrayPart
@ -146,10 +146,6 @@ Produces roughly this C code:
NI data[];
} MySeq;
The bounds checking done at compile time is not disabled for now, so to access
``s.data[C]`` (where ``C`` is a constant) the array's index needs to
include ``C``.
The base type of the unchecked array may not contain any GC'ed memory but this
is currently not checked.

View file

@ -130,7 +130,7 @@ Two identifiers are considered equal if the following algorithm returns true:
.. code-block:: nim
proc sameIdentifier(a, b: string): bool =
a[0] == b[0] and
a.replace(re"_|–", "").toLower == b.replace(re"_|–", "").toLower
a.replace("_", "").toLower == b.replace("_", "").toLower
That means only the first letters are compared in a case sensitive manner. Other
letters are compared case insensitively and underscores are ignored.

View file

@ -248,12 +248,20 @@ calls can use the ``do`` keyword:
.. code-block:: nim
sort(cities) do (x,y: string) -> int:
cmp(x.len, y.len)
# Less parenthesis using the method plus command syntax:
cities = cities.map do (x:string) -> string:
"City of " & x
# In macros, the do notation is often used for quasi-quoting
macroResults.add quote do:
if not `ex`:
echo `info`, ": Check failed: ", `expString`
``do`` is written after the parentheses enclosing the regular proc params.
The proc expression represented by the do block is appended to them.
In calls using the command syntax, the do block will bind to the immediately
preceeding expression, transforming it in a call.
``do`` with parentheses is an anonymous ``proc``; however a ``do`` without
parentheses is just a block of code. The ``do`` notation can be used to
@ -275,8 +283,8 @@ Nonoverloadable builtins
The following builtin procs cannot be overloaded for reasons of implementation
simplicity (they require specialized semantic checking)::
declared, defined, definedInScope, compiles, low, high, sizeOf,
is, of, shallowCopy, getAst, astToStr, spawn, procCall
declared, defined, definedInScope, compiles, sizeOf,
is, shallowCopy, getAst, astToStr, spawn, procCall
Thus they act more like keywords than like ordinary identifiers; unlike a
keyword however, a redefinition may `shadow`:idx: the definition in

View file

@ -189,12 +189,28 @@ resides in its own directory so that the generated ``nimcache`` directory
is not shared between different projects.
Compiler Selection
==================
To change the compiler from the default compiler (at the command line)::
nim c --cc:llvm_gcc --compile_only myfile.nim
This uses the configuration defined in ``config\nim.cfg`` for ``lvm_gcc``.
If nimcache already contains compiled code from a different compiler for the same project,
add the ``-f`` flag to force all files to be recompiled.
The default compiler is defined at the top of ``config\nim.cfg``. Changing this setting
affects the compiler used by ``koch`` to (re)build Nim.
Cross compilation
=================
To cross compile, use for example::
nim c --cpu:i386 --os:linux --compile_only --gen_script myproject.nim
nim c --cpu:i386 --os:linux --compileOnly --genScript myproject.nim
Then move the C code and the compile script ``compile_myproject.sh`` to your
Linux i386 machine and run the script.
@ -262,6 +278,15 @@ Define Effect
what's in the Nim file with what's in the C header
(requires a C compiler with _Static_assert support, like
any C11 compiler)
``tempDir`` This symbol takes a string as its value, like
``--define:tempDir:/some/temp/path`` to override the
temporary directory returned by ``os.getTempDir()``.
The value **should** end with a directory separator
character. (Relevant for the Android platform)
``useShPath`` This symbol takes a string as its value, like
``--define:useShPath:/opt/sh/bin/sh`` to override the
path for the ``sh`` binary, in cases where it is not
located in the default location ``/bin/sh``
================== =========================================================

View file

@ -138,7 +138,7 @@ comments can also be nested.
]#
]#
You can also use the `discard statement`_ together with *long string
You can also use the `discard statement <#procedures-discard-statement>`_ together with *long string
literals* to create block comments:
.. code-block:: nim
@ -364,8 +364,7 @@ iterator:
echo i
# --> Outputs 1 2 3 4 5 6 7 8 9 10 on different lines
The built-in `$ <system.html#$>`_ operator turns an integer (``int``) and many
other types into a string. The variable ``i`` is implicitly declared by the
The variable ``i`` is implicitly declared by the
``for`` loop and has the type ``int``, because that is what `countup
<system.html#countup>`_ returns. ``i`` runs through the values 1, 2, .., 10.
Each value is ``echo``-ed. This code does the same:
@ -501,10 +500,6 @@ differences:
The ``when`` statement is useful for writing platform specific code, similar to
the ``#ifdef`` construct in the C programming language.
**Note**: To comment out a large piece of code, it is often better to use a
``when false:`` statement than to use real comments. This way nesting is
possible.
Statements and indentation
==========================

View file

@ -218,7 +218,7 @@ So "pure object oriented" code is easy to write:
import strutils, sequtils
stdout.writeLine("Give a list of numbers (separated by spaces): ")
stdout.write(stdin.readLine.split.map(parseInt).max.`$`)
stdout.write(stdin.readLine.splitWhitespace.map(parseInt).max.`$`)
stdout.writeLine(" is the maximum!")
@ -233,15 +233,15 @@ is needed:
type
Socket* = ref object of RootObj
host: int # cannot be accessed from the outside of the module due to missing star
h: int # cannot be accessed from the outside of the module due to missing star
proc `host=`*(s: var Socket, value: int) {.inline.} =
## setter of host address
s.host = value
s.h = value
proc host*(s: Socket): int {.inline.} =
## getter of host address
s.host
s.h
var s: Socket
new s
@ -723,7 +723,7 @@ regular expressions:
.. code-block:: nim
macro case_token(n: typed): typed =
macro case_token(n: varargs[untyped]): typed =
# creates a lexical analyzer from regular expressions
# ... (implementation is an exercise for the reader :-)
discard