• Re: another simple defmacro question

    From B. Pym@21:1/5 to Thomas A. Russ on Thu Sep 12 04:57:08 2024
    XPost: comp.lang.scheme

    Thomas A. Russ wrote:

    Not at all connected with your original problem, but you can
    exploit the full power of LOOP to greatly simplify this part
    of the code:

    (let ((stringlist)
    (tmpstr))
    (with-open-file (infile fname :direction :input)
    (loop
    (setq tmpstr (read-line infile nil nil))
    (unless tmpstr
    (return))
    (push tmpstr stringlist)
    ))
    (setq stringlist (nreverse stringlist))
    stringlist
    ))

    It can be transformed into:

    (with-open-file (infile fname :direction :input)
    (loop for tmpstr = (read-line infile nil nil)
    while tmpstr
    collect tmpstr))

    It's somewhat shorter in Gauche Scheme.

    (call-with-input-file "output.dat" port->string-list)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)