basic-command.scm 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. ; Copyright (c) 1993-2008 by Richard Kelsey and Jonathan Rees. See file COPYING.
  2. ; run
  3. (define-command-syntax 'run "<exp>" "evaluate an expression" '(expression))
  4. (define (run exp)
  5. (evaluate-and-select exp (environment-for-commands)))
  6. ; exit-when-done
  7. (define-command-syntax 'exit-when-done "[<status>]"
  8. "leave Scheme after all threads finish"
  9. '(&opt expression))
  10. (define (exit-when-done . exp-option)
  11. (let ((status (if (null? exp-option)
  12. 0
  13. (eval (car exp-option) (environment-for-commands)))))
  14. (terminate-command-processor! status)))
  15. (define-command-syntax 'exit
  16. "[<status>]"
  17. "leave Scheme now"
  18. '(&opt expression))
  19. (define (exit . exp-option)
  20. (let ((status (if (null? exp-option)
  21. 0
  22. (eval (car exp-option) (environment-for-commands)))))
  23. (scheme-exit-now status)))
  24. ; go
  25. (define-command-syntax 'go "<exp>" "leave Scheme via tail recursion"
  26. '(expression))
  27. (define (go exp)
  28. (let ((env (environment-for-commands)))
  29. (exit-command-processor (lambda () (eval exp env)))))
  30. ; load
  31. (define-command-syntax 'load "<filename> ..."
  32. "load Scheme source file(s)"
  33. '(&rest filename))
  34. (define (load . filenames)
  35. (apply really-load load-into filenames))
  36. (define-command-syntax 'load-script "<filename> ..."
  37. "load Scheme script(s)"
  38. '(&rest filename))
  39. (define (load-script . filenames)
  40. (apply really-load load-script-into filenames))
  41. (define (really-load load-into . filenames)
  42. (let ((env (environment-for-commands)))
  43. ;; (with-interaction-environment env
  44. ;; (lambda ()
  45. ((if (load-noisily?)
  46. (lambda (x) (x))
  47. silently)
  48. (lambda ()
  49. (noting-undefined-variables env
  50. (lambda ()
  51. (for-each (lambda (filename)
  52. (load-into filename env))
  53. filenames)))))));; ))
  54. ; help
  55. (define ? help)
  56. (define-command-syntax 'help
  57. "[<command-name>]"
  58. "list all commands, or give help on a specific command"
  59. '(&opt name))
  60. (define-command-syntax '? "[<command-name>]" "same as ,help" '(&opt name))