Merge branch 'master' of github.com:Araq/Nimrod

This commit is contained in:
Araq
2013-01-08 22:55:00 +01:00
3 changed files with 43 additions and 38 deletions

View File

@@ -439,39 +439,39 @@ Exception hierarchy
If you want to create your own exceptions you can inherit from E_Base, but you
can also inherit from one of the existing exceptions if they fit your purpose.
The exception tree is:
The exception tree is::
* E_Base
* EAsynch
* EControlC
* ESynch
* ESystem
* EIO
* EOS
* EInvalidLibrary
* EResourceExhausted
* EOutOfMemory
* EStackOverflow
* EArithmetic
* EDivByZero
* EOverflow
* EAccessViolation
* EAssertionFailed
* EInvalidValue
* EInvalidKey
* EInvalidIndex
* EInvalidField
* EOutOfRange
* ENoExceptionToReraise
* EInvalidObjectAssignment
* EInvalidObjectConversion
* EFloatingPoint
* EFloatInvalidOp
* EFloatDivByZero
* EFloatOverflow
* EFloatUnderflow
* EFloatInexact
* EDeadThread
* E_Base
* EAsynch
* EControlC
* ESynch
* ESystem
* EIO
* EOS
* EInvalidLibrary
* EResourceExhausted
* EOutOfMemory
* EStackOverflow
* EArithmetic
* EDivByZero
* EOverflow
* EAccessViolation
* EAssertionFailed
* EInvalidValue
* EInvalidKey
* EInvalidIndex
* EInvalidField
* EOutOfRange
* ENoExceptionToReraise
* EInvalidObjectAssignment
* EInvalidObjectConversion
* EFloatingPoint
* EFloatInvalidOp
* EFloatDivByZero
* EFloatOverflow
* EFloatUnderflow
* EFloatInexact
* EDeadThread
See the `system <system.html>`_ module for a description of each exception.

View File

@@ -63,3 +63,9 @@ template filterIt*(seq1, pred: expr): expr {.immediate, dirty.} =
if pred: result.add(it)
result
template toSeq*(iter: expr): expr {.immediate.} =
## Transforms any iterator into a sequence.
var result {.gensym.}: seq[type(iter)] = @[]
for x in iter: add(result, x)
result

View File

@@ -1,12 +1,11 @@
discard """
output: "23456"
output: "2345623456"
"""
template toSeq*(iter: expr): expr {.immediate.} =
var result: seq[type(iter)] = @[]
for x in iter: add(result, x)
result
import sequtils
for x in toSeq(countup(2, 6)):
stdout.write(x)
for x in items(toSeq(countup(2, 6))):
stdout.write(x)