Add string-index start arg; add Error? aliases for Chez compat
ober
bdf842a594df212a5c84707b70ab082b91e59ef3
--- a/lib/std/error.sls +++ b/lib/std/error.sls @@ -5,7 +5,8 @@ (export error? error-message error-irritants error-trace Error ContractViolation - raise-error with-exception-handler) + raise-error with-exception-handler + Error? Error-message Error-irritants) (import (chezscheme)) ;; In Chez, errors are conditions. Provide Gerbil-compatible access. @@ -45,4 +46,9 @@ (make-message-condition message) (make-irritants-condition irritants)))) + ;; Gerbil class-style aliases (match gherkin's runtime/error.sls) + (define Error? error?) + (define Error-message error-message) + (define Error-irritants error-irritants) + ) ;; end library --- a/lib/std/misc/string.sls +++ b/lib/std/misc/string.sls @@ -88,13 +88,22 @@ [(string=? (substring str i (+ i slen)) sub) i] [else (loop (+ i 1))])))) - (define (string-index str ch) - (let ([len (string-length str)]) - (let loop ([i 0]) - (cond - [(= i len) #f] - [(char=? (string-ref str i) ch) i] - [else (loop (+ i 1))])))) + (define string-index + (case-lambda + [(str ch) + (let ([len (string-length str)]) + (let loop ([i 0]) + (cond + [(= i len) #f] + [(char=? (string-ref str i) ch) i] + [else (loop (+ i 1))])))] + [(str ch start) + (let ([len (string-length str)]) + (let loop ([i start]) + (cond + [(= i len) #f] + [(char=? (string-ref str i) ch) i] + [else (loop (+ i 1))])))])) (define (string-empty? str) (zero? (string-length str)))