[plt-scheme] Duplicate code

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Mon May 28 15:15:21 EDT 2007

On May 28, 2007, at 10:11 AM, Grant Rettke wrote:

> Hi folks,
>
> Inside of that let block is the custom code, and that let block is in
> a couple of places.
>
> (let* ([path (get-file-path editor)]
>        [prev/timestamp (mem-timestamp path)]
>        [fs/timestamp (fs-timestamp path)])
>
> I'm wondering if there is any way to, or if it would even make sense,
> to clean it up.
>
> Thoughts?


1. Is a second-order function okay?

(define (grant action)
   (define path ...)
   (define prev ...)
   (define stmp ...)
   (action path prev stmp))

2. If not, try a macro.



> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme



Posted on the users mailing list.