Vladimir Sedach

Have Emacs - Will Hack

October 12, 2012

Enforcing required slot values in Common Lisp structs and classes

I was reading a blog post by Robert Smith on ideas for future directions for Lisp type systems, where Robert mentioned the following very neat hack to enforce provision of required slot values for structures and classes:

(defstruct foo
  (slot1 (error "Must provide value for slot1")))