You are looking at historical revision 26277 of this page. It may differ significantly from its current revision.

Simple-Configuration aka Sexp-Configurtion

Introduction

This is a small scheme library to hande configurations in a simple manner. It uses lists as the basic datastructure to hold configurations.

Examples

(use simple-configuration)

(define my-config
 '((production
    (database
      (username "prod")
      (password "prodpwd")
      (host "test.example.com")))
   (development
    (database
      (username "dev")
      (password "devpwd")
      (host "dev.example.com")))
  (logging
   (destination "/var/log/application.log")
   (levels (error warning)))))

;; now you can access the data like so

(config-ref my-config '(production database username)) ;; => "prod"
(config-ref my-config '(production database))          ;; => (username "prod")
(config-ref my-config '(production database))   ;; => ((username "prod") (password "prodpwd") (host "test.example.com"))

(config-let my-config ((db-user (production database username))
                       (db-pw   (production database password))
                       (db-host (production database host)))
  (connect-to-database db-host db-user db-pw))

;; postprocess data
(config-ref my-config '(logging levels) post-process: (lambda (ls) (cons 'critical ls))) ;; => (critical error warning)

Authors

David Krentzlin

Api

[procedure] (config-read port-or-path #!key (eval-config #f))

Reads the configuration from the given port or path. If eval-config is set to #t then the entire config is evaled inside a quasiquote.

[procedure] (config-ref cfg path #!key (default #f) (post-process identity))

Extract a value from the configuration.

[syntax] (config-let ((binding path) ...) body ...)