FWIW, reasons like this is why most of the standard libraries have #f or some other simple value for a default. Then, the "real" default is computed in the body. <br><br>Robby<br><br>On Saturday, February 11, 2012, Laurent <<a href="mailto:laurent.orseau@gmail.com">laurent.orseau@gmail.com</a>> wrote:<br>
> Hi,<br>> Often I'd like to make a wrapper for a given function that has default values (possibly with keywords).<br>> So if I want my function to have the same default values for one particular optional argument, I need to redefine it myself.<br>
> For example, suppose there already exists a function foo like this:<br>> (define (foo arg1 [arg2 <some-complicated-default-value>])<br>> ....)<br>> And I want to make a wrapper for foo on arg1, but keep foo's arg2 default value:<br>
> (define (bar [arg2 <the-same-complicated-default-value>])<br>> (foo 5 arg2))<br>> But I don't feel right when I need to redefine the default argument, for a few reasons:<br>> - I feel bar should not need to know foo's arg2 default value.<br>
> - if arg2 has a complicated default argument, it is "painful" and error-prone to rewrite it (and if the docs for the default value for arg2 are simplified, it may be problematic),<br>> - if the specification of foo's arg2 changes, I need to change bar too (though sometimes bar's arg2 needs not reflect the change, but often it does),<br>
> I would prefer something like:<br>> (define (bar [arg2 (get-default-value foo arg2)])<br>> (foo 5 arg2))<br>> which is transparent w.r.t. foo.<br>> Does this feature exist, or does it even have a name? Or can it be easily implemented (maybe keywords could help)?<br>
> Thanks,<br>> Laurent