Re: assert (and assume) Peter McGoron 30 Nov 2026 04:29 UTC

I would rather see them combined. Here is a very preliminary sketch:

___________________________

     (assume disable-flags expression who message irritants ...)
     syntax

Disable-flags is a list of identifiers.

If any of the identifiers in disable-flags is a cond-expand flag, then
it is an error if `expression` evaluates to false. [This is the behavior
of SRFI 145 assume].

Otherwise, if `expression` evaluates to false, an assertion violation is
raised, with `who` as the who field, the `message` as the message field,
and `irritants` as the irritants. [This is the behavior of assert,
extended.]

SRFI 145 assume could be defined as:

     (define-syntax srfi-145-assume
       (syntax-rules ()
         ((_ expression message irritants ...)
          (assume (ndebug) #f expression message irritants ...))))

Assert could be defined as

     (define-syntax assert
       (lambda (x)
         (syntax-case x ()
           ((_ expression)
            (let ((message (syntax-object->string expression)))
              #`(assume () #f #,message expression))))))

(The definition of `syntax-object->string` is not important.)

_____________________________

This would allow for fine-grained control over assertion disabling (for
instance, disabling internal type checks vs disabling type checks on the
user-facing API). It would also allow for unconditionally enabled
assertions (R6RS asserts).

-- Peter McGoron