<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
On 2/11/2012 10:55 AM, Laurent wrote:
<blockquote
cite="mid:CABNTSaGVwk+nHAShLhU5ieHWe0dmLcFvbwFx8iiuLbG1L0TEcQ@mail.gmail.com"
type="cite">Hi,
<div><br>
</div>
<div>Often I'd like to make a wrapper for a given function that
has default values (possibly with keywords).</div>
<div>So if I want my function to have the same default values for
one particular optional argument, I need to redefine it myself.</div>
<div><br>
</div>
<div>For example, suppose there already exists a function foo like
this:</div>
<div><br>
</div>
<div>(define (foo arg1 [arg2
<some-complicated-default-value>])</div>
<div> ....)</div>
<div><br>
</div>
<div>
And I want to make a wrapper for foo on arg1, but keep foo's
arg2 default value:</div>
<div><br>
</div>
<div>(define (bar
[arg2 <the-same-complicated-default-value>])</div>
<div> (foo 5 arg2))</div>
<div><br>
</div>
<div>
But I don't feel right when I need to redefine the default
argument, for a few reasons:</div>
<div>- I feel bar should not need to know foo's arg2 default
value.</div>
<div>- 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),</div>
<div>- 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),</div>
<div><br>
</div>
<div>I would prefer something like:</div>
<div><br>
</div>
<div>(define (bar [arg2 (get-default-value foo arg2)])</div>
<div> (foo 5 arg2))</div>
<div><br>
</div>
<div>which is transparent w.r.t. foo.</div>
<div><br>
</div>
<div>Does this feature exist, or does it even have a name? Or can
it be easily implemented (maybe keywords could help)?</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Laurent</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">____________________
Racket Users list:
<a class="moz-txt-link-freetext" href="http://lists.racket-lang.org/users">http://lists.racket-lang.org/users</a>
</pre>
</blockquote>
<br>
</body>
</html>