Skip to content
This repository has been archived by the owner on Jan 16, 2021. It is now read-only.

Commit

Permalink
1448 - infinite loops in extensible def/mac.. gone.
Browse files Browse the repository at this point in the history
But tests now take 8x more time to run!
  • Loading branch information
akkartik committed Jan 20, 2012
1 parent 6712935 commit a7fb204
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
1 change: 0 additions & 1 deletion 032check.wart
@@ -1,4 +1,3 @@
= compiled-if if
let $if if
mac! if args
$if !cdr.args
Expand Down
5 changes: 5 additions & 0 deletions 035generic.test
Expand Up @@ -10,3 +10,8 @@ def foogen(s . rest) :case (and !rest sym?.s)
(test "def :case can handle rest params - 2"
:valueof foogen!a
:should be 'a)

(test "mac :case avoids infinite loops"
:valueof (mac if args :case (or nil nil)
34)
:should ~be nil) ; return successfully
10 changes: 6 additions & 4 deletions 035generic.wart
Expand Up @@ -7,13 +7,15 @@ def construct-macro-call(args)

let $mac mac
mac! mac(name params . body)
compiled-if (~iso :case car.body)
if (~iso :case car.body)
`(,$mac ,name ,params ,@body)
`(let $super ,name
(mac! ,name ,params
compiled-if ,cadr.body
(do ,@cddr.body)
,(construct-macro-call (cons '$super params)))) ; call super with params
(dyn_bind ,name $super)
ret $ans (if ,cadr.body
(do ,@cddr.body)
,(construct-macro-call (cons '$super params))) ; call super with params
(dyn_unbind ,name)))

mac def(name params . body) :case (iso :case car.body)
`(let $old ,name
Expand Down
6 changes: 0 additions & 6 deletions 036control.wart
Expand Up @@ -98,9 +98,3 @@ def andf fs
:else
(and (car.fs @args) (self cdr.fs))))
(sub fs)))



; pattern matching
mac if args :case nil ;(iso 'let car:car.args) ;(match car.args '(let . _))
34

0 comments on commit a7fb204

Please sign in to comment.