(ql:quickload 'defstar)
(use-package 'defstar)
(declaim (optimize (debug 3) (speed 0) (safety 3)))
(defun* factorial ((x (integer 0 *))) ;; x is an integer from 0 up to +inf
(if (zerop x)
1
(* x (factorial (1- x)))))
(defun main ()
(factorial "foo") ;; Compile time error: "foo" conflicts with its assert type UNSIGNED-BTYE
(factorial -1) ;; Compile time error: -1 conflicts with its assert type UNSIGNED-BTYE
(factorial 1.0) ;; Compile time error: 1.0 conflicts with its assert type UNSIGNED-BTYE
(factorial 0)) ;; Works
And when you load the file into SBCL you get the following error message (assuming you have Quicklisp installed): $ sbcl --load compile-time-safety.lisp
This is SBCL 1.2.7, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.
SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
To load "defstar":
Load 1 ASDF system:
defstar
; Loading "defstar"
; file: /home/rol/src/lisp/compile-time-safety.lisp
; in: DEFUN MAIN
; (FACTORIAL "foo")
;
; caught WARNING:
; Constant "foo" conflicts with its asserted type UNSIGNED-BYTE.
; See also:
; The SBCL Manual, Node "Handling of Types"
;
; compilation unit finished
; caught 1 WARNING condition
It's not as nice as Haskell's type system, but it's something :) (setq gnus-blocked-images ".*")
will block all the images in the emails.
--
[1] - https://www.quicklisp.org/beta/ [2] - Don't know if there is a similar package for Scheme.