diff options
-rw-r--r-- | doc/lib.txt | 5 | ||||
-rw-r--r-- | lib/pure/typetraits.nim | 23 | ||||
-rw-r--r-- | web/nimrod.ini | 2 |
3 files changed, 26 insertions, 4 deletions
diff --git a/doc/lib.txt b/doc/lib.txt index 5bacfcc4f..76e7354e0 100644 --- a/doc/lib.txt +++ b/doc/lib.txt @@ -56,7 +56,10 @@ Core * `typeinfo <typeinfo.html>`_ Provides (unsafe) access to Nimrod's run time type information. - + +* `typetraits <typetraits.html>`_ + This module defines compile-time reflection procs for working with types. + * `actors <actors.html>`_ Actor support for Nimrod; implemented as a layer on top of the threads and channels modules. diff --git a/lib/pure/typetraits.nim b/lib/pure/typetraits.nim index e7bd363cf..3203ee699 100644 --- a/lib/pure/typetraits.nim +++ b/lib/pure/typetraits.nim @@ -11,7 +11,26 @@ ## working with types proc name*(t: typedesc): string {.magic: "TypeTrait".} - ## Returns the name of the given type + ## Returns the name of the given type. + ## + ## Example: + ## + ## .. code-block:: + ## + ## import typetraits + ## + ## proc `$`*[T](some:typedesc[T]): string = name(T) + ## + ## template test(x): stmt = + ## echo "type: ", type(x), ", value: ", x + ## + ## test 42 + ## # --> type: int, value: 42 + ## test "Foo" + ## # --> type: string, value: Foo + ## test(@['A','B']) + ## # --> type: seq[char], value: @[A, B] + proc arity*(t: typedesc): int {.magic: "TypeTrait".} - ## Returns the arity of the given type \ No newline at end of file + ## Returns the arity of the given type diff --git a/web/nimrod.ini b/web/nimrod.ini index 544446b11..38a906ac5 100644 --- a/web/nimrod.ini +++ b/web/nimrod.ini @@ -41,7 +41,7 @@ doc: "tools;niminst;nimgrep;gc;estp;idetools;docgen;koch;backends.txt" pdf: "manual;lib;tut1;tut2;nimrodc;niminst;gc" srcdoc2: "system.nim;impure/graphics;wrappers/sdl" srcdoc2: "core/macros;pure/marshal;core/typeinfo;core/unsigned" -srcdoc2: "impure/re;pure/sockets" +srcdoc2: "impure/re;pure/sockets;pure/typetraits" srcdoc: "system/threads.nim;system/channels.nim;js/dom" srcdoc2: "pure/os;pure/strutils;pure/math;pure/matchers;pure/algorithm" srcdoc2: "pure/complex;pure/times;pure/osproc;pure/pegs;pure/dynlib" |