3 ms·
The function checks for a type with assert: (assert (stringp arg)). But that check is a documented behavior which generates a predictable exception that the ca
by kazinator 3y ago
The function checks for a type with assert: (assert (stringp arg)). But that check is a documented behavior which generates a predictable exception that the caller can detect and so can tell when that is suddenly missing.
No matter what consequence you give to the failed check, something can break when the check is taken away.
We could have a True(r) Scotsman's checked precondition like this
(unless (stringp arg)
(abort)) ;; bail the entire process image with abnormal status
If we check it like that, nobody will try to depend on the behavior within an application, in the way that my test program did.
It can still be a breaking change if the function is written that way, and then changed so the abort is taken away. Because the application can do this:
(defun my-stupid-abort ()
(strlen nil)) ;; this calls abort!
So now if the program relies on (my-stupid-abort) to abort, that will break; suddenly that function call returns zero and the process keeps going.
You really need:
;; ... ffi definitions here ...
(unless (stringp arg)
(acpi-power-off))
But again, dumb program can depend on (strlen nil) to power of the machine, which could be part of some critical system that breaks as a result of it not powering off.
Only a compile time check can do it, by preventing the program from existing. A program that never compiled and therefore was never deployed to its installation will never break.