Permalink
Browse files

Adding in racket-#f, catcherr, and load-curdir

`pipe-from` now uses Arc's stderr, so error messages should work okay now

`quit` now works just like racket-exit, so it accepts an argument now
  • Loading branch information...
Pauan committed May 23, 2011
1 parent ab99346 commit 382987aafc1d7af48e78abd60ee6381faf510de4
Showing with 46 additions and 37 deletions.
  1. +10 −8 arc
  2. +25 −26 arc.arc
  3. +7 −1 base.arc
  4. +2 −2 lib/re.arc
  5. +2 −0 readme.md
View
18 arc
@@ -46,11 +46,13 @@
; this should work, but says "undefined variable: _"
;((g load) (string-append (g srcdir) "arc3.1/strings.arc"))
- (cond (exec-all
- (for-each (g load) files-to-load))
- ((pair? files-to-load)
- ((g load) (car files-to-load))))
-
- (when (or run-repl (null? files-to-load))
- ((g load) (string-append (g srcdir) "repl.arc"))
- (noprint ((g repl))))))
+ (let ((load (g load-curdir)))
+
+ (cond (exec-all
+ (for-each load files-to-load))
+ ((pair? files-to-load)
+ (load (car files-to-load))))
+
+ (when (or run-repl (null? files-to-load))
+ ((g load) (string-append (g srcdir) "repl.arc"))
+ (noprint ((g repl)))))))
View
51 arc.arc
@@ -656,7 +656,7 @@
(rev ,ga))))
(def aracket-false (x)
- (is x (racket "#f")))
+ (is x racket-#f))
(def aracket-true (x)
(not (aracket-false x)))
@@ -1200,15 +1200,6 @@
(racket-expand-user-path v)))
(fn (v) (racket-path->string v))))
-#|
-this is now handled by ifdlet, so I should probably remove this...
-
-(mac w/curdir (val . body)
- (w/uniq x
- `(iflet ,x ,val
- (dlet curdir ,x ,@body)
- (let curdir curdir ,@body))))
-|#
(def expandpath (x)
(zap string x)
@@ -1325,27 +1316,36 @@ this is now handled by ifdlet, so I should probably remove this...
; Input
;=============================================================================
-(def load (file)
-; (prn file)
-; (ifdlet curdir (dirname (joinpath curdir file)))
-; (w/curdir file ;(absdir file)
+(def load-curdir (file)
+ (w/infile f file
+ (w/uniq eof
+ (whiler e (read f eof) eof
+ (eval e)))))
+
+(def make-w/curdir (f)
+ (fn (file . rest)
+ (w/curdir (dirname file)
+ (apply f (basename file) rest))))
+
+(= load (make-w/curdir load-curdir))
+
+#|(def load (file)
(w/curdir (dirname file)
-; (prn curdir)
- (w/infile f (basename file)
- (w/uniq eof
- (whiler e (read f eof) eof
- (eval e))))))
+ (load-curdir (basename file))))|#
; should pipe-from call (cont 'wait)?
(def pipe-from (cmd)
- (let (in out id err cont) (ar-toarc:racket-process cmd)
- ; Racket docs say I need to close all 3 ports explicitly. Obviously I
- ; can't close the input port, since that's what we're returning, but
- ; I wonder if it's really necessary to close the output and error ports...
+ (let (in out id err cont) (ar-toarc:racket-process/ports racket-#f
+ racket-#f
+ stderr
+ cmd)
+ ; Racket docs say I need to close all 3 ports explicitly
(close out)
- (close err)
in))
+;>>> (pipe-from "echo hi 1>&2")
+;hi
+
#|
doesn't work:
@@ -1560,8 +1560,7 @@ doesn't work:
0
(/ (count test xs) (len xs))))
-(def quit ()
- (racket-exit))
+(= quit racket-exit)
(def find (test seq)
(let f (testify test)
View
@@ -13,6 +13,10 @@
`(on-err (fn (c) nil)
(fn () ,expr)))
+(mac catcherr (expr)
+ `(on-err (fn (c) (details c))
+ (fn () ,expr nil)))
+
;=============================================================================
; Variable binding
@@ -517,8 +521,10 @@
(def call-with-semaphore (sema func)
((racket call-with-semaphore) sema (fn () (func))))
+(assign racket-#f (racket "#f"))
+
(def nil->racket-false (x)
- (if (not x) (racket "#f") x))
+ (if (not x) racket-#f x))
(def make-thread-cell (v (o preserved))
(racket-make-thread-cell v (nil->racket-false preserved)))
View
@@ -4,7 +4,7 @@
(mac pref (x y)
`(= ,x (+ ,y ,x)))
-#|(defrule ac (racket-eq? s (racket #f))
+#|(defrule ac (racket-eq? s racket-#f)
nil)|#
#|(defrule ac (racket-bytes? s)
@@ -16,7 +16,7 @@
(pref re "^"))
(= next t)
(let x (racket-regexp-match re str)
- (if (isnt x (racket #f))
+ (if (isnt x racket-#f)
(racket->string x)
(cont nil)))))
View
@@ -98,6 +98,8 @@ Todo
* readlines
* pipe-from
* load (don't forget to test that it handles subdirectories correctly)
+ * quit
+ * catcherr
* templates
* cache, defcache
* until

0 comments on commit 382987a

Please sign in to comment.