Add syntax-length to unstable/syntax.

This commit is contained in:
Eric Dobson 2013-05-25 00:09:03 -07:00
parent 83f38f4d3b
commit 0d771fb4f1
2 changed files with 18 additions and 0 deletions

View File

@ -100,6 +100,15 @@ Performs @racket[(map f (syntax->list stxl) ...)].
(syntax-map syntax-e #'(a b c))]
}
@addition{@author+email["Eric Dobson" "eric.n.dobson@gmail.com"]}
@defproc[(syntax-length [stx syntax?]) exact-nonnegative-integer?]{
Performs @racket[(length (syntax->list stx))].
@examples[#:eval the-eval
(syntax-length #'(d e f))]
}
@addition[@author+email["Carl Eastlund" "cce@racket-lang.org"]]
@section{Syntax Object Source Locations}

View File

@ -7,6 +7,9 @@
(provide (rename-out [stx-map syntax-map])
;; by endobson
syntax-length
;; by cce:
syntax-source-file-name
syntax-source-directory
@ -103,3 +106,9 @@
[(id . args)
(let ([stx* (cons #'(#%expression id) (cdr (syntax-e stx)))])
(datum->syntax stx stx* stx))]))))
;; by endobson
(define (syntax-length stx)
(let ((list (syntax->list stx)))
(and list (length list))))