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

From: Jordan Schatz (jordan at noionlabs.com)
Date: Sun Jan 8 15:23:59 EST 2012

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


Posted on the users mailing list.