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

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Sun Jan 8 22:19:49 EST 2012

FWIW, arguments in Racket are always passed on a stack.


On Sun, Jan 8, 2012 at 9:12 PM, Gregory Woodhouse <gregwoodhouse at me.com> wrote:
> I suppose it could prevent certain optimizations in parameter passing, forcing space for arguments to be allocated on the heap.
> Sent from my iPad
> On Jan 8, 2012, at 12:42 PM, Danny Yoo <dyoo at cs.wpi.edu> wrote:
>> On Sun, Jan 8, 2012 at 3: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?
>> Hi Jordan,
>> Can you give an example of such a language?  I'm curious.
>> I'm not sure where the inefficiency would come from, unless computing
>> the default value expression's value is costly.
>> According to the documentation in:
>> http://docs.racket-lang.org/reference/lambda.html#(form._((lib._racket/private/base..rkt)._lambda))
>> with regards to "default-expr": "... if no such argument is provided,
>> the default-expr is evaluated to produce a value associated with id."
>> From the reference docs, it sounds like that, unlike a language like
>> Python, the default value is evaluated for every use of the function,
>> rather than just once when the function's defined.  We can experiment
>> with this:
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

Posted on the users mailing list.