varg.ss

(import varg)

This is a chicken scheme egg, section structure will be like:

Authors

Repository

https://codeberg.org/rikuri/varg.ss/

Requirements

API

Exception

Exceptions is supposed to be compliant with the module (chicken condition) and SRFI-12

Find more details about exception in the specific procedure below

non-continuable

The non-continuable conditions expand system conditions from:

More specifically, they would be:

(varg . |args|)

Return

(varg |args|) will return a list that contain:

Parameters

|args| in (varg |args|) should be a sequence that contain 1 or more element listed below, order is not sensitive:

Examples

Bascially varg filter the input list by conditions, and group them to 3 classes #:with-value withou-value #:literal. for example

(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"
)

For another example, a procedure that copy file to another path named cp

Just showing how to use varg, no copy implementation in cp

(define (cp . cp-args)
	(varg
		'(#:with-value #:mode)
		'(#:without-value #:force)
		'(#:literal src dest)
		cp-args
	)
... ...
)

cp would be called like:

License

MIT