From 48c17bd85209b96aa496105f69f3b91ba48284c9 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Wed, 3 Aug 2016 10:44:33 -0700 Subject: [PATCH] make `format-datum` return void on empty input --- beautiful-racket-lib/br/datum.rkt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/beautiful-racket-lib/br/datum.rkt b/beautiful-racket-lib/br/datum.rkt index 32013ec..66cf650 100644 --- a/beautiful-racket-lib/br/datum.rkt +++ b/beautiful-racket-lib/br/datum.rkt @@ -3,12 +3,14 @@ (provide (all-defined-out)) ;; read "foo bar" the same way as "(foo bar)" -;; other "bar" is dropped, which is too astonishing +;; otherwise "bar" is dropped, which is too astonishing (define (string->datum str) - (let ([result (read (open-input-string (format "(~a)" str)))]) - (if (= (length result) 1) - (car result) - result))) + (if (positive? (string-length str)) + (let ([result (read (open-input-string (format "(~a)" str)))]) + (if (= (length result) 1) + (car result) + result)) + (void))) #;(define-syntax format-datum (λ(stx)