EmilySeville7cfg · 2022-12-20 11:29
(cl-defstruct person (name :read-only :type string) (age :read-only :type integer))
(make-person :name "Elise" :age "a") ;; Expected error for `:age`: string passed but integer expected
But if I made mistake in `cl-defstruct` definition why there was no error in the first line?
ieure · 2022-12-20 17:13
Lisp is a dynamic/weak typed language, and you're asking for static/strong typed behavior.
Perhaps the `:type` argument is intended for user documentation, and not enforced; or it might exist for compatibility, but be ignored. You'd have to look at the source of the `cl-defstruct` macro to determine why the behavior varies form your expectations.