cat from sex-macros should accept more than two arguments at a time #75

Open
opened 2026-11-03 17:04:59 +01:00 by alex-eg · 0 comments
Owner

cat and cat-syms in sex-macros.scm are fixed at two arguments:

(define (cat-syms s-1 s-2)
  (fmt #f s-1 s-2))

(define (cat sym-1 sym-2)
  (string->symbol (cat-syms sym-1 sym-2)))

Macro authors building a name from more than two pieces therefore have to nest:

(cat (cat 'list- type) '-node)

and a direct call fails:

(cat 'a 'b 'c)
;; Error: expanding foo: bad argument count - received 3 but expected 2:
;; #<procedure (sex-macros#cat sym-1 sym-2)>

Please make cat and cat-syms variadic, preserving the current behavior for two arguments:

(cat 'a 'b 'c)   ; => abc
(cat 'a)         ; => a
(cat)            ; => error probably?

cat-syms should have the same arity behavior and return the concatenated string.

cat is injected into every macro body via (only sex-macros cat comment), so making it variadic is source-compatible and would remove the nesting noise from macros that generate longer names.

Tests: add cases for 0, 1, 2, and 3+ arguments for both cat and cat-syms, and keep the existing two-argument behavior covered.

`cat` and `cat-syms` in `sex-macros.scm` are fixed at two arguments: ```scheme (define (cat-syms s-1 s-2) (fmt #f s-1 s-2)) (define (cat sym-1 sym-2) (string->symbol (cat-syms sym-1 sym-2))) ``` Macro authors building a name from more than two pieces therefore have to nest: ```scheme (cat (cat 'list- type) '-node) ``` and a direct call fails: ```scheme (cat 'a 'b 'c) ;; Error: expanding foo: bad argument count - received 3 but expected 2: ;; #<procedure (sex-macros#cat sym-1 sym-2)> ``` Please make `cat` and `cat-syms` variadic, preserving the current behavior for two arguments: ```scheme (cat 'a 'b 'c) ; => abc (cat 'a) ; => a (cat) ; => error probably? ``` `cat-syms` should have the same arity behavior and return the concatenated string. `cat` is injected into every macro body via `(only sex-macros cat comment)`, so making it variadic is source-compatible and would remove the nesting noise from macros that generate longer names. Tests: add cases for 0, 1, 2, and 3+ arguments for both `cat` and `cat-syms`, and keep the existing two-argument behavior covered.
alex-eg added the feature label 2026-11-03 17:04:59 +01:00
Sign in to join this conversation.