<div dir="ltr">Since there's little background here, I thought I'd just add that this feature you're coming across is one of the critical things that underpins Racket and differentiates it from languages like python and ruby. That is, what you're seeing is that Racket has a way to make unforgeable values. This ability is (in addition to lots of stuff, notably macros) is what makes it possible for Racket's class system to be a library and lots of other things that you'd expect to be built into a language to also be libraries. <div>
<br></div><div>As a little example, if you have these files:</div><div><br></div><div>;; a.rkt</div><div>#lang racket</div><div><div>(struct url (stuff more-stuff))</div></div><div><br></div><div>;; b.rkt</div><div>#lang racket</div>
<div>(struct url (stuff more-stuff))</div><div><br></div><div>;; c.rkt</div><div>#lang racket</div><div>(require (prefix-in a: "a.rkt") (prefix-in b: "b.rkt"))</div><div>(b:url-stuff (a:url 1 2))</div>
<div><br></div><div><br></div><div>you'll see an error message very similar to the one you reported.</div><div><br></div><div>It is the struct declaration's location (technically when it is evaluated -- you can even stick them inside functions and each time you call the function you get a different notion of "url") that determines which is which.</div>
<div><br></div><div>This is why, for example, you cannot see the hidden stuff inside the class and object structs. Or, for that matter functions! The "lambda" that #lang racket exports is a lot fancier than the low-level built-in lambda, and that is all implemented with structs. Indeed, you cannot tell what is primitive and what is implemented with a struct in some private file (unless you read the source code). Or, to put it another way: everything is implemented with struct and the runtime system is just good at optimizing a small subset of the structs where performance matters.</div>
<div><br></div><div>Robby</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Oct 23, 2013 at 5:38 PM, Erik Pearson <span dir="ltr"><<a href="mailto:erik@adaptations.com" target="_blank">erik@adaptations.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="im">On Wed, Oct 23, 2013 at 3:31 PM, Jay McCarthy <span dir="ltr"><<a href="mailto:jay.mccarthy@gmail.com" target="_blank">jay.mccarthy@gmail.com</a>></span> wrote:<br>
</div><div class="gmail_extra"><div class="gmail_quote"><div class="im">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Here are two ideas.<br>
<br>
1) You simply have an old use of the original net/url. When #<url> is<br>
printed, it uses the symbolic name and you can't really figure out<br>
what the underlying code came from. I would do a grep to make sure<br>
this is not the case.<br></blockquote><div><br></div></div><div>Would the operative places to look be the point at which the url object is created and then where it is used? In other words, if it is created in the context of net/url (i.e. a module where net/url is required) and used in a module with adaptnet/url required, it will look like a #<url> (when printed) but not be a url? according to adaptnet/url's url-structs, and where the object travels in between doesn't make a difference?</div>
<div><div class="h5">
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
2) You are using namespaces somewhere and actually have two instances<br>
of the same module somewhere where a value produced by copy 1 is going<br>
to copy 2. This is possible with the Web server if you don't set up<br>
the servlet namespace properly:<br>
<br>
<a href="http://docs.racket-lang.org/web-server-internal/dispatch-servlets.html#(part._namespace)" target="_blank">http://docs.racket-lang.org/web-server-internal/dispatch-servlets.html#(part._namespace)</a><br>
<br>
On Wed, Oct 23, 2013 at 4:25 PM, Erik Pearson <<a href="mailto:erik@adaptations.com" target="_blank">erik@adaptations.com</a>> wrote:<br>
> Excuse my poor experience with contracts, this is probably an easy one.<br>
><br>
> I'm using a copy of net/url and have a strange problem. The copied library<br>
> is working fine in general, but this problem cropped up today:<br>
><br>
> struct:exn:fail:contract:blame url-port: contract violation<br>
> expected: url?<br>
> given: #<url><br>
> in: the 1st argument of<br>
> (-> url? (or/c #f number?))<br>
> contract from:<br>
> /home/epearson/work/racket/github/adaptnet/url-structs.rkt<br>
> blaming: /home/epearson/work/racket/github/racqueb/httpc.rkt<br>
> at: /home/epearson/work/racket/github/adaptnet/url-structs.rkt:4.28<br>
><br>
> The error is thrown in my usage of url-port which is being passed a<br>
> perfectly good url struct object. The file is requiring the copied<br>
> url-structs. If I play with the function that is being blamed in httpc.rkt<br>
> via the repl in dr racket, this specific error is not thrown. The call to<br>
> (url-port url) succeeds without throwing this contract exception.<br>
><br>
> From my primitive understanding, I'm flummoxed: Why is a #<url> not a url?<br>
><br>
> I suspected that there may have been a leftover require of net/url confusing<br>
> things, but I can't find any in my code.<br>
><br>
> Using racket head from github 5.90.0.9--2013-10-20(d6610289/d)<br>
><br>
> Help!<br>
><br>
> Thanks,<br>
> Erik.<br>
><br>
><br>
><br>
> ____________________<br>
> Racket Users list:<br>
> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
><br>
<span><font color="#888888"><br>
<br>
<br>
--<br>
Jay McCarthy <<a href="mailto:jay@cs.byu.edu" target="_blank">jay@cs.byu.edu</a>><br>
Assistant Professor / Brigham Young University<br>
<a href="http://faculty.cs.byu.edu/~jay" target="_blank">http://faculty.cs.byu.edu/~jay</a><br>
<br>
"The glory of God is Intelligence" - D&C 93<br>
</font></span></blockquote></div></div></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br>Erik Pearson<br>Adaptations<br>;; web form and function
</font></span></div></div>
<br>____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br></blockquote></div><br></div>