diff options
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 126 |
1 files changed, 95 insertions, 31 deletions
@@ -34399,6 +34399,10 @@ Additional objects that are not sequences are also iterable: numeric or character ranges, and numbers. Future revisions of the language may specify additional iterable objects. +Iterable objects are suitable arguments to the +.code iter-begin +function. + .coNP Functions @ make-like and @ seq-like .synb .mets (make-like < seq << object ) @@ -40086,6 +40090,53 @@ If .code seq is not an iterable object, an error exception is thrown. +.coNP Function @ iterp +.synb +.mets (iterp << obj ) +.syne +.desc +The +.code iterp +function returns +.code t +if +.meta obj +is an iterator object, otherwise +.codn nil . + +Note that this test is different from the +.code iterable +function, which tests whether it is possible to invoke +.code iter-begin +on an object to obtain an iterator. + +It is possible for an object to satisfy both +.code iterp +and +.codn iterable . + +The +.code iterp +function returns +.code t +for the following objects or types: +the empty list +.codn nil ; +conses, including lazy conses; +characters; and numbers both integer and floating-point. + +In addition, +.code iterp +returns +.code t +for struct objects which have an +.code iter-step +method. Note that such objects must satisfy additional +requirements to usefully behave as iterators. + +For all other objects, the function returns +.codn nil . + .coNP Function @ iter-more .synb .mets (iter-more << iter ) @@ -40101,11 +40152,19 @@ Otherwise it returns The .meta iter -argument must be a valid iterator returned by a call to -.metn iter-begin , -.meta iter-step -or -.metn iter-reset . +argument must be a valid iterator object, for which the +.code iterp +function returns +.codn t , +or else it must be a struct. As a special behavior in support +of the fast iteration protocol, if +.meta iter +is a struct which does not support the +.code iter-more +method, the +.code iter-more +function unconditionally returns +.codn t . The .code iter-more @@ -40189,6 +40248,11 @@ method, then .code t is returned. +For any other object, the +.code iter-more +throws an exception of type +.codn type-error . + .coNP Function @ iter-item .synb .mets (iter-item << iter ) @@ -40200,21 +40264,25 @@ function indicates that more items remain to be visited, then the next item can be retrieved using .codn iter-item . -The +Except if it is a struct, the .meta iter -argument must be a valid iterator returned by a call to -.metn iter-begin , -.meta iter-step -or -.metn iter-reset . +argument must be a valid iterator object, for which the +.code iterp +function returns +.codn t . +If +.meta iter +is a struct, it must implement the +.code iter-item +method. The -.code iter-more +.code iter-item function doesn't change the state of .metn iter . If -.code iter-more +.code iter-item is invoked on an iterator which indicates that no more items remain to be visited, the return value is .codn nil . @@ -40281,6 +40349,11 @@ is a structure which supports the .code iter-item method, then that method is called and its return value is returned. +For all other objects, +.code iter-item +throws an exception of type +.codn type-error . + .coNP Function @ iter-step .synb .mets (iter-step << iter ) @@ -40297,11 +40370,10 @@ remaining items in the sequence. The .meta iter -argument must be a valid iterator returned by a call to -.metn iter-begin , -.meta iter-step -or -.metn iter-reset . +argument must be a valid iterator object, for which the +.code iterp +function returns +.codn t . The .code iter-step @@ -40357,19 +40429,6 @@ and so on. If .meta iter -is a list-like sequence, then -.code cdr -is invoked on it and that value is returned. -The value must also be a list-like sequence, or else -.codn nil . -The reasoning for this is the same as for the similar -restriction imposed in the case when -.meta iter -is a -.codn cons . - -If -.meta iter is a character or number, then .code iter-step returns its successor, as if using the @@ -40382,6 +40441,11 @@ is a structure which supports the .code iter-step method, then that method is called and its return value is returned. +For all other objects, +.code iter-step +throws an exception of type +.codn type-error . + .coNP Function @ iter-reset .synb .mets (iter-reset < iter << seq ) |