;;; Random useful utilities. ;;; Excerpted from SCSH ;;; Copyright (c) 1993 Olin Shivers (define-module (scsh utilities) #:export (check-arg stringify loophole)) ;;; From guile-scsh/loophole.scm ;;; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. ;;; original file: alt/loophole.scm. (define-syntax loophole (syntax-rules () ((loophole ?type ?form) (begin (lambda () ?type) ;Elicit unbound-variable warnings, etc. ?form)))) ;;; We loophole the call to ERROR -- the point is that perhaps the ;;; user will interact with a breakpoint, and proceed with a new ;;; value, which we will then pass to a new invocation of CHECK-ARG ;;; for approval. (define (check-arg pred val caller) (if (pred val) val (check-arg pred (loophole :value (error "Bad argument" val pred caller)) caller))) ;;; is there any reason for this to be restricted and just not an ;;; alias for object->string? -- clinton (define (stringify thing) (cond ((string? thing) thing) ((symbol? thing) (symbol->string thing)) ((integer? thing) (number->string thing)) (else (error "Can only stringify strings, symbols, and integers." thing))))