Arc Forumnew | comments | leaders | submitlogin
4 points by rntz 3804 days ago | link | parent

Not a bug in '++, a bug in the ssyntax expansion process:

    arc> (ssexpand '++.n)
    arc> (ssexpand '.n)
    (get n)
Infix + triggers ssyntax for ac-andf - even+odd expands to (andf even odd), for example. However, the expander doesn't handle +'s in non-medial position very well - it just cuts them out:

    arc> (ssexpand '++foo)
Since medial + is checked before medial dot in ssyntax expansion, this leads '++.n to expand to '.n and thence to (get n).

4 points by rntz 3803 days ago | link

So it turns out '+ and '++ are actually special-cased in the ssyntax expansion process. From ac.scm:

    (define (ssyntax? x)
      (and (symbol? x)
           (not (or (eqv? x '+) (eqv? x '++) (eqv? x '_)))
           (let ((name (symbol->string x)))
             (has-ssyntax-char? name (- (string-length name) 1)))))
This is somewht ugly IMO, but it does mean that merely switching the order in which '. and '+ are ssexpanded fixes this particular bug:

    diff --git a/ac.scm b/ac.scm
    index 3304953..739a4f2 100644
    --- a/ac.scm
    +++ b/ac.scm
    @@ -89,9 +89,9 @@

     (define (expand-ssyntax sym)
       ((cond ((or (insym? #\: sym) (insym? #\~ sym)) expand-compose)
    +         ((or (insym? #\. sym) (insym? #\! sym)) expand-sexpr)
              ((insym? #\+ sym) expand-and)
          ;   ((insym? #\_ sym) expand-curry)
    -         ((or (insym? #\. sym) (insym? #\! sym)) expand-sexpr)
              (#t (error "Unknown ssyntax" sym)))
Albeit it does change the semantics of some "correct" uses of ssyntax slightly (though not in a way I'd expect anyone to rely on); for example, 'foo+bar.baz expands to '(andf foo (bar baz)) under arc3, but expands to '((andf foo bar) baz) with this patch applied.


3 points by pg 3801 days ago | link

Will fix.


5 points by pg 3796 days ago | link

Looks like the answer is to use & instead of +. I like the look of + better, but I can tell people are going to want to use it in names.


1 point by akkartik 3804 days ago | link

Ah, thanks. So this is a known problem?