Skip to content

Commit

Permalink
Make ac.scm reloadable
Browse files Browse the repository at this point in the history
  • Loading branch information
shawwn committed Feb 2, 2019
1 parent 0d556ec commit b0e33f7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 15 deletions.
25 changes: 15 additions & 10 deletions ac.scm
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
; sread = scheme read. eventually replace by writing read

(define (sread p (eof eof))
(port-count-lines! p)
(let ((expr (read-syntax (object-name p) p)))
(if (eof-object? expr) eof expr)))
(parameterize ((read-accept-lang #t)
(read-accept-reader #t))
(port-count-lines! p)
(let ((expr (read-syntax (object-name p) p)))
(if (eof-object? expr) eof expr))))

(define (syn x (src #f))
(if (syntax? x)
Expand Down Expand Up @@ -795,8 +797,8 @@
args)))
((arc-list? (car args))
(apply append args))
[(evt? (car args))
(apply choice-evt args)]
((evt? (car args))
(apply choice-evt args))
(#t (apply + args)))))

(define (char-or-string? x) (or (string? x) (char? x)))
Expand Down Expand Up @@ -1272,8 +1274,8 @@

(define-syntax-rule (get-here)
(begin
(let ([ccr (current-contract-region)])
(let-values ([(here-dir here-name ignored) (split-path ccr)])
(let ((ccr (current-contract-region)))
(let-values (((here-dir here-name ignored) (split-path ccr)))
(build-path here-dir here-name)))))

(define ac-load-path
Expand Down Expand Up @@ -1339,9 +1341,12 @@
(xdef eval arc-eval)

(define (seval s (ns (current-namespace)))
(if (syntax? s)
(eval-syntax s ns)
(eval s ns)))
(parameterize ((current-namespace ns)
(compile-allow-set!-undefined #t)
(compile-enforce-module-constants #f))
(eval (if (syntax? s)
(compile-syntax (namespace-syntax-introduce s))
(compile s)))))

(xdef seval seval)

Expand Down
14 changes: 10 additions & 4 deletions arc.arc
Original file line number Diff line number Diff line change
Expand Up @@ -1498,8 +1498,10 @@
(pr ,@(parse-format str))))
)

(^ loaded-files* (list "arc.arc" "libs.arc"))
(^ loaded-file-times* (obj "arc.arc" (modtime "arc.arc")))
(^ loaded-files* (list "ac.scm" "arc.arc" "libs.arc")
loaded-file-times* (obj "ac.scm" (modtime "ac.scm")
"arc.arc" (modtime "arc.arc")
"libs.arc" (modtime "libs.arc")))

(def loaded-files () (rev loaded-files*))

Expand All @@ -1510,12 +1512,16 @@
(= (loaded-file-times* file) secs)
value)

(def load-code (file)
(def arcfile? (file)
(and (> (len file) 4)
(is ".arc" (cut file (- (len file) 4)))))

(def load-code (file (o evalfn (if (arcfile? file) eval seval)))
(let x nil
(w/infile f file
(w/uniq eof
(whiler e (read f eof nil) eof
(= x (eval e)))))
(= x (evalfn e)))))
x))

(def load (file)
Expand Down
7 changes: 6 additions & 1 deletion arc.scm
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#lang racket/load

(require "ac.scm")
(compile-allow-set!-undefined #t)
(compile-enforce-module-constants #f)

(load "ac.scm")
(require 'ac)

(require "brackets.scm")
(use-bracket-readtable)

Expand Down

0 comments on commit b0e33f7

Please sign in to comment.