On 10/25/2016 06:16 PM, Dan Liebgold wrote:
On Tuesday, October 25, 2016 at 2:09:59 PM UTC-7, Ryan Culpepper wrote:

   racket -e '(enter! "your-module.rkt")' -i


BTW, any luck putting a line like this in csh shell script, alias, or windows 
batch file?

For scripting, if your interactions are already in a file somewhere, I would recommend something like this:

  ;; drjr : Module-Path Path-String -> Void
  (define (drjr defs-module ints-file)
    (namespace-require defs-module)
    (define mod-ns (module->namespace defs-module))
    (parameterize ((current-namespace mod-ns))
      (load ints-file)))

`module->namespace` is the primitive function used to implement `enter!`. Note that the interactions file is `load`ed, so it should not have a #lang line.

I've attached a program that wraps the function above as a program, so you can put the following in your scripts:

  racket drjr.rkt defs-module ints-file

If you did want an interactive version, you can replace the `(load ints-file)` above with `(read-eval-print-loop)`.

Ryan

--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
#lang racket/base
(provide drjr)

;; drjr : Module-Path Path-String -> Void
(define (drjr defs-module ints-file)
  (namespace-require defs-module)
  (define mod-ns (module->namespace defs-module))
  (parameterize ((current-namespace mod-ns))
    (load ints-file)))

(module+ main
  (require racket/cmdline raco/command-name)
  (command-line
   #:program (short-program+command-name)
   #:args (definitions-module interactions-file)
   (drjr `(file ,definitions-module) interactions-file)))

Reply via email to