[Prev][Next][Index][Thread]

Re: Critique a first prog?



Just one thought:

block also supports exception clause, so you could write the read-lines
thus:

define method read-lines(stream :: <stream>) => lines :: <vector>;
    let v = make(<stretchy-vector>);

    block ()
        while (#t)
            add!(v, read-line(stream));
        end;
    exception (<end-of-stream-error>)

    end block;
    v
end;

this expands essentially to what you wrote.

    Gabor (letting others comment too :-)



----------
In article <39CA550D.7964C1F8@jenkon.com>, Bryn Keller <brk@jenkon.com>
wrote:


> define method read-lines(stream :: <stream>)
>   let v = make(<stretchy-vector>);
>   block(exit)
>     let handler <end-of-stream-error>
>       = method(condition, next)
>      exit();
>  end;
>     while (#t)
>       add!(v, read-line(stream));
>     end;
>   end;
>   v;
> end;



References: