Skip to content

Commit

Permalink
mal: modify lib/ in order to hide bugs in make/ and guile/
Browse files Browse the repository at this point in the history
Make: avoid # character.
Guile: avoid `unquote` inside a vector inside a list inside `quasiquote`.
The bug in scheme/ is most probably the same.
  • Loading branch information
asarhaddon committed Jun 2, 2019
1 parent b483c43 commit 2dfe777
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/perf.mal
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
(fn* (exp)
(let* [start (gensym)
ret (gensym)]
`(let* [~start (time-ms)
~ret ~exp]
`(let* (~start (time-ms)
~ret ~exp)
(do
(prn (str "Elapsed time: " (- (time-ms) ~start) " msecs"))
~ret)))))
Expand Down
2 changes: 1 addition & 1 deletion lib/test_cascade.mal
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
(if (< (count xs) 2)
(first xs)
(let* [r (gensym)]
`(let* [~r ~(first xs)] (if ~r ~r (or ~@(rest xs))))))))
`(let* (~r ~(first xs)) (if ~r ~r (or ~@(rest xs))))))))

;; Conjonction of predicate values (pred x1) and .. and (pred xn)
;; Evaluate `pred x` for each `x` in turn. Return `false` if a result
Expand Down
4 changes: 2 additions & 2 deletions lib/trivial.mal
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
;; Returns the unchanged argument.
(def! identity (fn* (x) x))

;; Generate a hopefully unique symbol.
;; http://www.gigamonkeys.com/book/macros-defining-your-own.html#plugging-the-leaks
;; Generate a hopefully unique symbol. See section "Plugging the Leaks"
;; of http://www.gigamonkeys.com/book/macros-defining-your-own.html
(def! gensym
(let* [counter (atom 0)]
(fn* []
Expand Down

0 comments on commit 2dfe777

Please sign in to comment.