On Sat, Feb 11, 2012 at 15:07, Rodolfo Carvalho <rhcarva...@gmail.com>wrote:
> Hello, > > On Sat, Feb 11, 2012 at 14:55, Laurent <laurent.ors...@gmail.com> wrote: > >> ... >> >> (define (bar [arg2 (get-default-value foo arg2)]) >> (foo 5 arg2)) >> >> >> > Maybe someone will have a better idea (or a brighter implementation), but > if not, here's my contribution: > > .... > If we use #f for arg2 in foo, we can write: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; #lang racket (require rackunit) (define (foo arg1 [arg2 #f]) (+ arg1 (or arg2 10))) (define (bar [arg2 #f]) (let ([arg1 5]) (foo arg1 arg2))) (check-= (bar 2) 7 0) (check-= (bar) 15 0) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; This way it is not necessary to accommodate for calling foo with different number of args. All we need is to propagate the #f default value. []'s Rodolfo
____________________ Racket Users list: http://lists.racket-lang.org/users