Arc Forumnew | comments | leaders | submitlogin
Bug report: A and Not B makes arc hang
7 points by conanite 5552 days ago | discuss

  arc> a&~b
  [ time passes ...]
  ^Cuser break
Sometimes my logic classes echo back at me from years past, and I feel compelled to write A and not B, or in arc terms, hopefully, a&~b. Here's an example:

  arc> ; a function to detect multiples of d
  arc> (def m (d) (fn (n) (is (mod n d) 0))) 

  arc> ; odd numbers that are not multiples of 7.
  arc> (map odd&~m.7 (range 5 9))    
I would expect (t nil nil nil t), but it doesn't work! Arc just hangs.

Here is a possible solution that simply demotes ~-ssyntax, so that &-ssyntax gets expanded before ~. I can't tell if it might break other stuff though:

  ; ac.scm
  (define (expand-ssyntax sym)
    ((cond ((insym? #\: sym) expand-compose)
           ((or (insym? #\. sym) (insym? #\! sym)) expand-sexpr)
           ((insym? #\& sym) expand-and)
           ((insym? #\~ sym) expand-compose) ; ** demote complement **
       ;   ((insym? #\_ sym) expand-curry)
           (#t (error "Unknown ssyntax" sym)))
     sym))
This is only a quick fix; I think part of the underlying problem is that expand-ssyntax triggers expand-compose if it detects "~" anywhere in the symbol, but expand-compose only expands "~" when it occurs at the beginning of the symbol.