<div dir="ltr">So to trace calls to the interface functions of a library I am to write a gasket for the library.  I may as well put a display of the args in the gasket functions as at this point it is the same amount of code as hooking the trace.   Of course then I have implemented trace.  <div><br></div><div>So to use trace in racket all you have to do is implement trace ..   really??</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 19, 2015 at 10:06 PM, J. Ian Johnson <span dir="ltr"><<a href="mailto:ianj@ccs.neu.edu" target="_blank">ianj@ccs.neu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Yes, racket 101 (305?) is that identifiers can only be set!'d in their defining module. This is to allow necessary optimizations such as inlining.<br>
<br>
If you want to trace `f` from a different module. you can `(define (g . args) (apply f args)) (trace g)`, use `g` wherever you use `f`. You won't get any calls the library makes internally, but if you're just tracing for your own code, you'll be golden.<br>
<br>
-Ian<br>
<div><div class="h5"><br>
----- Original Message -----<br>
From: "Thomas Lynch" <<a href="mailto:thomas.lynch@reasoningtechnology.com">thomas.lynch@reasoningtechnology.com</a>><br>
To: "users" <<a href="mailto:users@racket-lang.org">users@racket-lang.org</a>><br>
Sent: Monday, January 19, 2015 8:59:55 AM<br>
Subject: [racket] trace: set!: cannot mutate module-required identifier - alright .. how do you do this?<br>
<br>
Saw this in another thread here, but the proposed solution didnt work, well at least the way I understood it. So ..<br>
<br>
In file db-lib.rkt I have a definition:<br>
<br>
<br>
<br>
<br>
(provide db-exec)<br>
(define (db-exec a) ...)<br>
<br>
Then in racket<br>
<br>
<br>
<br>
<br>
> (enter! "db-user.rkt")<br>
<br>
Where db-citation.rkt has<br>
<br>
<br>
<br>
<br>
(require "db-lib.rkt")<br>
<br>
Now at the read-eval-print prompt I try<br>
<br>
<br>
<br>
<br>
(enter! "db-citation.rkt")<br>
<br>
And when I do (trace db-exec) I get the cannot mutate error. (Surely this must be a racket 101 type problem.) So I try to include the module at the current scope..<br>
<br>
<br>
<br>
<br>
racket@db-citation.rkt> (require "db-lib.rkt")<br>
racket@db-citation.rkt> (require racket/trace)<br>
racket@db-citation.rkt> (trace db-exec)<br>
<br>
racket@db-citation.rkt> stdin::1130: set!: cannot mutate module-required identifier in: db-exec<br>
ok, so that doesn't work, so I start over again. This time after reading the thread on this list<br>
<br>
<br>
<br>
<br>
From: Vincent St-Amour (stamourv at <a href="http://ccs.neu.edu" target="_blank">ccs.neu.edu</a> )<br>
Date: Mon Oct 10 13:49:46 EDT 2011<br>
<br>
which concludes by saying 'put the trace in your program that should work', so I add this to "db-citation.rkt"<br>
<br>
<br>
<br>
<br>
(require racket/trace)<br>
(trace db-exec)<br>
<br>
And then at the prompt I get the following:<br>
<br>
<br>
<br>
<br>
Welcome to Racket v5.2.1.<br>
racket@> (enter! "db-citation.rkt")<br>
db-citation.rkt:26:11: set!: cannot mutate module-required identifier in: db-exec<br>
<br>
Alright, so what is the magic incantation here that allows one to debug/trace calls in included modules?<br>
<br>
Thanks!<br>
<br>
Thomas<br>
<br>
</div></div>____________________<br>
  Racket Users list:<br>
  <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</blockquote></div><br></div>