[racket] Unreachable line reached
On 17/09/12 19:23, Danny Yoo wrote:
>
> Hi Paolo,
>
>
> When I look at the program more closely, I think the structure of the
> iteration might be improved with a "for" loop and the match library.
> I'm trying to avoid let loops these days just because they remind me
> too much of GOTO-sytle programming. :)
>
Embarrassingly when I started using Scheme we didn't have for loops so I
actually have never used them but I will take a look at their syntax.
>
> Here's my take on your snippet:
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> (for ([line (in-lines in)])
> (match (string-split line ",")
> [(list path modtime-str md5-str)
> (define modtime (string->number (string-trim modtime-str)))
> (define md5 (string->bytes/utf-8 (string-trim md5-str)))
why not let for these?
I have always heard these kind of define's would be poor style. What's
your take on this?
> (cond
> [(or (not path) (not modtime) (not md5))
> (printf "[2] read-cache fails, unexpected line in cache file:
> ~a, ignoring.~n" line)]
> [else
> (hash-set! (*cache*) path (cons modtime md5))])]
> [else
> (printf "[1] read-cache fails, unexpected line in cache file: ~a,
> ignoring.~n" line)]))
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
Looks much better. Thanks.
>
> Good luck!
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users
>
--
PMatos