Thanks for the info.<br><br><div class="gmail_quote">On Thu, Sep 16, 2010 at 12:27 AM, Robby Findler <span dir="ltr"><<a href="mailto:robby@eecs.northwestern.edu">robby@eecs.northwestern.edu</a>></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>
"unfun" 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'm surprised it'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'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'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 <<a href="mailto:markku.rontu@iki.fi">markku.rontu@iki.fi</a>> wrote:<br>
> Hi everybody,<br>
><br>
> I don't understand what the difference is with define and define/contract in<br>
> the following cases. Can somebody explain what happens here? Especially why<br>
> does unfun not eq? itself?!?<br>
><br>
> #lang racket<br>
><br>
> (define (fun) 'fun)<br>
> (define/contract (unfun) (-> symbol?) 'unfun)<br>
> (define fun? (contract (-> symbol?) fun 'fun '!fun))<br>
><br>
>> (eq? fun fun)<br>
> #t<br>
>> (eq? unfun unfun)<br>
> #f<br>
>> (eq? fun? fun?)<br>
> #t<br>
><br>
> Thanks,<br>
> -Markku<br>
><br>
</div></div>> _________________________________________________<br>
> For list-related administrative tasks:<br>
> <a href="http://lists.racket-lang.org/listinfo/users" target="_blank">http://lists.racket-lang.org/listinfo/users</a><br>
><br>
</blockquote></div><br>