implemented return type inference
Other fixes: * bind once is now the default for type classes as documented in the manual * fixes an issue in template overloading (erroneous ambiguity when different typedesc params were used)
This commit is contained in:
parent
b28fcdfa93
commit
7e44015491
9 changed files with 104 additions and 36 deletions
|
|
@ -2940,6 +2940,13 @@ from the proc body. This is usually used with the ``auto`` type class:
|
|||
.. code-block:: nimrod
|
||||
proc makePair(a, b): auto = (first: a, second: b)
|
||||
|
||||
The return type will be treated as additional generic param and can be
|
||||
explicitly specified at call sites as any other generic param.
|
||||
|
||||
Future versions of nimrod may also support overloading based on the return type
|
||||
of the overloads. In such settings, the expected result type at call sites may
|
||||
also influence the inferred return type.
|
||||
|
||||
Symbol lookup in generics
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
@ -3431,7 +3438,7 @@ typedesc
|
|||
|
||||
`typedesc` is a special type allowing you to treat types as compile-time values
|
||||
(i.e. if types are compile-time values and all values have a type, then
|
||||
typedesc must be their type).
|
||||
typedesc must be their type).
|
||||
|
||||
When used as a regular proc param, typedesc acts as a type class. The proc
|
||||
will be instantiated for each unique type parameter and you can refer to the
|
||||
|
|
@ -3642,15 +3649,20 @@ proc with no side effects:
|
|||
|
||||
destructor pragma
|
||||
-----------------
|
||||
`RAII`:idx:
|
||||
`automatic variables`:idx:
|
||||
`destructors`:idx:
|
||||
|
||||
The `destructor` pragma is used to mark a proc to act as a type destructor.
|
||||
The proc must have a single parameter, having a concrete type.
|
||||
The proc must have a single parameter with a concrete type (the name of a
|
||||
generic type is allowed too).
|
||||
|
||||
Destructors will be automatically invoked when a local stack variable goes
|
||||
out of scope. If a record type features a field with destructable type and
|
||||
out of scope.
|
||||
|
||||
If a record type features a field with destructable type and
|
||||
the user have not provided explicit implementation, Nimrod will automatically
|
||||
generate a destructor for the record type.
|
||||
generate a destructor for the record type. Nimrod will automatically insert
|
||||
calls to any base class destructors in both user-defined and generated
|
||||
destructors.
|
||||
|
||||
|
||||
procvar pragma
|
||||
--------------
|
||||
|
|
@ -3658,7 +3670,6 @@ The `procvar`:idx: pragma is used to mark a proc that it can be passed to a
|
|||
procedural variable.
|
||||
|
||||
|
||||
|
||||
compileTime pragma
|
||||
------------------
|
||||
The `compileTime`:idx: pragma is used to mark a proc to be used at compile
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue