Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Such re-definitions are possible with <code>#lang racket</code> if you do them in the definitions window. The thing to keep in mind is that this is <em>not</em> a kind of mutation (which is common with R5RS implementations), for example, this:</p> <pre><code>#lang racket (define orig-+ +) (define + whatever) </code></pre> <p>will not have <code>orig-+</code> bound to the real addition function. When this module is compiled, Racket knows (statically) that <code>+</code> is something that you define, so any references to it are references to your own definition -- so the above code will bind <code>orig-+</code> to the "uninitialized" value of <code>+</code>. If you really want to do something like that, then you can require the original <code>+</code> under a different name:</p> <pre><code>#lang racket (require (rename-in racket [+ orig-+])) (define + whatever) </code></pre> <p>On top of that, there's inlining that happens when the module is compiled -- which is a different issue. Racket will usually want to inline references to bindings that are never mutated in the code, so if you try that last piece of code you will not be able to further redefine <code>+</code> on the REPL. You can deal with that in one of two ways -- the first is to mutate the binding explicitly:</p> <pre><code>#lang racket (require (rename-in racket [+ orig-+])) (define + #f) (set! + whatever) </code></pre> <p>which makes the compiler avoid any inlining. Another option is that DrRacket flag, which turns on a compiler flag that avoids all inlining. Note that the speed penalty for this can be significant.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload