varg

A template for defining dynamic arguments procedure.

varg is hosted in codeberg:

The latest document is:


For convenient, here is a example from the link above. Note that example here may be out of date.

(import varg)
(define (fun . args)
	(set! varg-output (varg
		'(#:with-value #:wi1 #:wi2)
		'(#:without-value #:wo1 #:wo2)
		'(#:literal #:li1 #:li2)
		args))
	; After the call of `fun` at the bottom,
	; varg-output should be a list:
	'(
		(#:with-value (#:wi1 . 1))
		; #:wi2 does not appear
		; because the call of `fun` at the bottom did not set it
		(#:without-value #:wo2)
		(#:literal "non-keyword1" "non-keyword2")
	)

	; Hence get values like this:
	(let
		(
			(with-value (cdr (assoc #:with-value varg-output)))
			(without-value (cdr (assoc #:without-value varg-output)))
			(literal (cdr (assoc #:literal varg-output)))
		)
		(print (cdr (assoc #:wi1 with-value))) ; this will be 1
		(print (member #:wo2 without-value)) ; this will be equal to #t
		(print (member #:wo1 without-value)) ; this will be #f
		(print (list-ref literal 0)) ; this will "non-keyword1"
		(print (list-ref literal 1)) ; this will "non-keyword2"
	)
)
(fun
	'(#:wi1 . 1)
	#:wo2
	"non-keyword1" "non-keyword2"
)