The `load` function can load a module declaration, but it doesn't
instantiate the module.

In other words, using `load` is like

```
 > (module m racket/base
     (define (neq . args) (not (apply = args)))
     (provide neq))
 > (neq 1 0)
 neq: undefined;
  cannot reference an identifier before its definition
   in module: 'program
```

But `require` loads the module, instantiates it, and imports the
module's `provide`s, so using `require` on a file is analogous to

```
 > (module m racket/base
     (define (neq . args) (not (apply = args)))
     (provide neq))
 > (require 'm)
 > (neq 1 0)
 #t
```

As you observe, `racket` doesn't track changes to files, and `require`
doesn't re-load a module that it has previously loaded (even if the
module's source changed).

You might want to try a tool like `xrepl`, which supports re-loading
changed modules:

  http://docs.racket-lang.org/xrepl/index.html


At Thu, 7 May 2015 22:02:38 -0700 (PDT), Thomas Lynch wrote:
> Her is a small pointless program
> 
>   #lang racket
>   (define (neq args) (not (apply = args)))
>   (provide neq)
> 
> So then loading this in racket:
> 
> racket@> (load "temp-lib.rkt")
> racket@> (neq 1 0)
> neq: undefined;
>  cannot reference undefined identifier
>   context...:
>    /usr/share/racket/collects/racket/private/misc.rkt:87:7
> 
> 
> Why is neq undefined after the load?  I could see symbols in a module with 
> load before the upgrade ..
> 
> Now there is a (provide neq) in there so why not use require?  Lets try 
> that in the same session:
> 
> racket@> (require "temp-lib.rkt")
> racket@> (neq 1 0)
> neq: arity mismatch;
>  the expected number of arguments does not match the given number
>   expected: 1
>   given: 2
>   arguments...:
>    1
>    0
>   context...:
>    /usr/share/racket/collects/racket/private/misc.rkt:87:7
> 
> 
> Yes, now the symbol can be seen. Good, and oh yeah, a '.'is missing in the 
> source so let me add that.  The edited and saved source code now appears as:
> 
> #lang racket
> (define (neq . args) (not (apply = args)))
> (provide neq)
> 
> 
> So again, in the same session, lets use this new better source code:
> 
> racket@> (neq 1 0)
> neq: arity mismatch;
>  the expected number of arguments does not match the given number
>   expected: 1
>   given: 2
>   arguments...:
>    1
>    0
>   context...:
>    /usr/share/racket/collects/racket/private/misc.rkt:87:7
> 
> 
> Alas, racket does seem to see the updated code.  My guess is that the 
> second require did nothing because racket already though it had that file. 
> Is this the case?  Anyway, I did this twice in different variations, and 
> indeed new edits do not come in.  Well then what to do, here I kill the 
> racket process and run it again (kinda like rebooting windows after a 
> problem):
> 
> racket@> 
> It's been nice interacting with you!
> Press C-c C-z to bring me back.
> Welcome to Racket v6.1.
> racket@> (require "temp-lib.rkt")
> racket@> (neq 1 0)
> #t
> racket@> 
> racket@> (require "temp-lib.rkt")
> racket@> (neq 1 0)
> #t
> racket@> 
> 
> 
> Yes, after rebooting racket I see my changes.
> 
> Ok, what is going on here?  What happened to load?  How do I load a file so 
> that I can work on it while seeing all the bindings?  How do I reload a 
> file after an edit?    
> 
> 
> 
>  
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email 
> to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-dev/76ffc46f-7231-4bf1-aa66-e873904ff18
> 1%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
```
Output:
```
program:40:57: read: illegal use of `.'

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-dev/20150509160956.08DDD6501CC%40mail-svr1.cs.utah.edu.
For more options, visit https://groups.google.com/d/optout.

Reply via email to