# HG changeset patch # User Steve Losh # Date 1650499831 14400 # Node ID 351848b6eab471da50ec51fe3cc18e7f24bd16de # Parent a55e0be16f56373839224c699915fed6755a4885 Bonus diff -r a55e0be16f56 -r 351848b6eab4 content/blog/2022/04/fun-with-macros-do-file.markdown --- a/content/blog/2022/04/fun-with-macros-do-file.markdown Tue Apr 19 09:46:21 2022 -0400 +++ b/content/blog/2022/04/fun-with-macros-do-file.markdown Wed Apr 20 20:10:31 2022 -0400 @@ -241,3 +241,16 @@ It can take any reader function that conforms to the usual `(read-foo stream eof-error-p eof-value)` interface, which means we can write our own reader functions that will compose nicely with the macro. + +We'll end with an exercise for the reader: figure out how to support +declarations correctly. For example: + +```lisp +(do-file (n "numbers.txt" :reader #'read-fixnum) + (declare (type fixnum n)) + (when (primep n) + (collect (* n n)))) +``` + +Hint: you'll need to deal with the sentinel value a bit differently so it +doesn't contaminate the type of the bound variable.