From c1c059356cd6f1a6320226050f10761c1b987606 Mon Sep 17 00:00:00 2001 From: Araq Date: Wed, 25 Jul 2012 23:34:16 +0200 Subject: fixes #171 --- doc/manual.txt | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/doc/manual.txt b/doc/manual.txt index ddfe594a8..665ca265c 100755 --- a/doc/manual.txt +++ b/doc/manual.txt @@ -2958,6 +2958,47 @@ In templates identifiers can be constructed with the backticks notation: In the example ``name`` is instantiated with ``myint``, so \`T name\` becomes ``Tmyint``. + +Lookup rules for template parameters +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +A parameter ``p`` in a template is even substituted in the expression ``x.p``. +Thus template arguments can be used as field names and a global symbol can be +covered by the same argument name even when fully qualified: + +.. code-block:: nimrod + # module 'm' + + type + TLev = enum + levA, levB + + var abclev = levB + + template tstLev(abclev: TLev) = + echo abclev, " ", m.abclev + + tstLev(levA) + # produces: 'levA levA' + +But the global symbol can properly be captured by a ``bind`` statement: + +.. code-block:: nimrod + # module 'm' + + type + TLev = enum + levA, levB + + var abclev = levB + + template tstLev(abclev: TLev) = + bind m.abclev + echo abclev, " ", m.abclev + + tstLev(levA) + # produces: 'levA levB' + Macros ------ -- cgit 1.4.1-2-gfad0 lass='active' href='/danisanti/profani-tty/blame/src/plugins/callbacks.c?id=a77a57a6a45ed07c60b31f7cbe977f8e68fadbc8'>blame commit diff stats
path: root/src/plugins/callbacks.c
blob: 4a73f15b1406e434ce34d12a94f8128229ddba2c (plain) (tree)
1
2
3
4
5