[racket] a question of style, and one of performance

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Sun Jan 8 15:35:17 EST 2012

I think you want parameterize:

(parameterize ([date-display-format 'rfc2822])
  (date->string i #t))

In general:

  ((lambda () e1 e2 ...)) = (begin e1 e2 ...)

fwiw. So that extra function there isn't going to help.

Robby

On Sun, Jan 8, 2012 at 2:23 PM, Jordan Schatz <jordan at noionlabs.com> wrote:
> This code runs, but I'm guessing that its not the "right way" to do it.
>
> (define (js-date [i (current-date)])
>  (let ([original-format (date-display-format)]
>        [return ((λ ()
>                     (date-display-format 'rfc2822)
>                     (date->string i #t)))])
>    (date-display-format original-format)
>    return))
>
> 1) In "some other language" using a function as the default value for an
> argument is inefficient and frowned upon. Is that the case in racket?
>
> 2) I want to set the date-format back to whatever it was before the
> function ran, so (date-display-format original-format) seems like it
> should go last, but I need my return value... What I have looks hacky,
> whats the "correct" way to do it?
>
> Thanks!
> Jordan
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users



Posted on the users mailing list.