std-assert


Synopsis

(std-assert <test> <msg>)

Description

STD-ASSERT evaluates the test argument and throws an assertion error if the result of the evaluation returns nil. The error uses the msg argument which may be a list or a string.

This is used for testing and debugging. It gives you some kind of assurance when debugging with dynamical data. It may be outcommented when the application is to be released, but better leave it in to help you in understanding error reports from users.

Examples

(std-assert '(> n 10) nil)	=> nil
(std-assert '(std-enamep ele) "no ename")	=> nil
(std-assert '() nil)
; *** Assertion Failure: nil => nil
; *** ERROR: quit / exit abort

;; assure that all elements are functions:

(setq val '(princ prin1))
(std-assert '(std-every 'std-functionp val)) "no function")

Arguments

test: any valid lisp expression. Most likely a quoted list which is to be evaluated as function.

msg: a string or a list.

Return Value

Always nil.

Side Effects

This is a typical function only used for its side effect.

Module

(std-require 'STDLISP)

Defined in STDLISP