macro for (dolist)-like function
Posted: Sat Oct 01, 2005 11:22 am
I want to write something like:
to simplify processing of large files with regular substructures (for example - csv or ldif) in record-by-record basis - without reading-in whole file.
where
sym is symbol name like exactly such one in (dolist) - not predefined and existing locally to dofile contents.
filespec can be value or expression that results in str-filename or int-fd.
opts are optional arguments like record delimiter other than \n, or buffer size for (read-buf) etc.
My trouble is about a way to handle sym in macro function. Only way I found is to compose lambda like
and to call it in dofile internal loop.
Is this the best choice?
Code: Select all
(dofile (sym filespec opts) (some-code))
where
sym is symbol name like exactly such one in (dolist) - not predefined and existing locally to dofile contents.
filespec can be value or expression that results in str-filename or int-fd.
opts are optional arguments like record delimiter other than \n, or buffer size for (read-buf) etc.
My trouble is about a way to handle sym in macro function. Only way I found is to compose lambda like
Code: Select all
(let (sym dofile-current-record-value) (some-code))
Is this the best choice?