Thanks for the info.<br><br><div class="gmail_quote">On Thu, Sep 16, 2010 at 12:27 AM, Robby Findler <span dir="ltr">&lt;<a href="mailto:robby@eecs.northwestern.edu">robby@eecs.northwestern.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Contracts are implemented by creating wrapper functions and<br>
define/contract does this by changing how the variable reference<br>
&quot;unfun&quot; works. It actually creates the wrapper function at the point<br>
of the variable reference and so is creating two in this case.<br></blockquote><div><br>My next question might have been how have you implemented contracts, i.e. how do you attach contracts to procedures? In this case you definitely need to wrap the procedure so that the contract gets called in the appropriate places but I&#39;m surprised it&#39;s done at the reference site and not in the definition.<br>
 </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
I expect that at some point define/contract may change in the future<br>
to create fewer wrappers; as you can probably guess in this case the<br>
wrappers are identical so we only need one. Probably this exact case<br>
won&#39;t change but others may.<br>
<br>
In general, when contracts are involved, you cannot rely on eq?-based<br>
identity for procedures. If you want some kind of identity on<br>
procedures, I recommend you use applicable structs.<br></blockquote><div> </div><div>What I&#39;m trying to do is to attach certain metadata to procedures. So I need a way to map from procedures to their metadata. Any ideas on how to implement this? Am I really forced to wrap everything behind my own wrapper that provides me a workable identity for each procedure? <br>
<br>So there is no reliable way to refer to procedures and attach the metadata but that I need to always custom-define and wrap them? This would mean there is no reliable way to attach metadata to third party procedures that may or may not be defined with define/contract? Or I have to make require to wrap everything required too somehow? Then there is of course the question of macros and attaching metadata to them...<br>
<br>In general, it would be nice to have a standard way of attaching metadata to any value. Or is this a silly idea?<br><br>-Markku<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

Robby<br>
<div><div></div><div class="h5"><br>
On Wed, Sep 15, 2010 at 3:10 PM, Markku Rontu &lt;<a href="mailto:markku.rontu@iki.fi">markku.rontu@iki.fi</a>&gt; wrote:<br>
&gt; Hi everybody,<br>
&gt;<br>
&gt; I don&#39;t understand what the difference is with define and define/contract in<br>
&gt; the following cases. Can somebody explain what happens here? Especially why<br>
&gt; does unfun not eq? itself?!?<br>
&gt;<br>
&gt; #lang racket<br>
&gt;<br>
&gt; (define (fun) &#39;fun)<br>
&gt; (define/contract (unfun) (-&gt; symbol?) &#39;unfun)<br>
&gt; (define fun? (contract (-&gt; symbol?) fun &#39;fun &#39;!fun))<br>
&gt;<br>
&gt;&gt; (eq? fun fun)<br>
&gt; #t<br>
&gt;&gt; (eq? unfun unfun)<br>
&gt; #f<br>
&gt;&gt; (eq? fun? fun?)<br>
&gt; #t<br>
&gt;<br>
&gt; Thanks,<br>
&gt; -Markku<br>
&gt;<br>
</div></div>&gt; _________________________________________________<br>
&gt;  For list-related administrative tasks:<br>
&gt;  <a href="http://lists.racket-lang.org/listinfo/users" target="_blank">http://lists.racket-lang.org/listinfo/users</a><br>
&gt;<br>
</blockquote></div><br>