From 22686584f103d163a1e5f370aa06905ec5c3b4a4 Mon Sep 17 00:00:00 2001 From: colin Date: Mon, 17 Jun 2024 21:13:41 -0700 Subject: Inital Commit --- README.md | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 README.md (limited to 'README.md') diff --git a/README.md b/README.md new file mode 100644 index 0000000..bfe785c --- /dev/null +++ b/README.md @@ -0,0 +1,66 @@ +# `def` + +A stupid project to dull the pain of using a few of CL's built-in `def*` forms. + +## `def:var` + +Isn't it annoying that, if you want to leave a `defvar`-defined +special variable uninitialized at the top-level, then you're not +allowed to give that variable a docstring? + +Sure, you can always + + (setf (documentation *my-speical* 'variable) "oh good, docs") + +but that's irritating too. + +Enter `def:var` + + + (def:var *oh-so-special* :doc "It's oh-so-special") + +Of course, you may still initialize the variable: + + (def:var *oh-so-special* :init (random 10) :doc "It's oh-so-special") + +## `def:const` + +Even more obnoxious is the behavior of `defconst` whenever you `C-c +C-c` in SLIME. You nearly always find yourself invoking a `CONTINUE` +restart when, according to common sense, you should not have had to. + +Well no more! + + (def:const +its-ten+ 10 "It's just the number 10") + +If you re-evaluate that form, then nothing annoying happens. Of +course, the form still expands out to `defconstant` so that a +condition signals whenever you try to `setf` the name. + +## `def:class` + +Admittedly, this one is less justfifed. There's already the extremely +elaborate `defclass/std` in the `defclass-std` system available +through quicklisp. But I think `defclass/std` is a little *too* +thorough and ends up getting in its own way. + +The case for using a macro like this is that, well, most classes are +defined in a very repetitive way. This macro just saves you some +work: + + (def:class pt () + (x y z :prefix :type real :initform 0) + (uuid :ro :type integer :initform (make-uuid) :documentation "A unique ID") + :documentation "A point in real 3d space") + +The above would expand out into + + (DEFCLASS PT NIL + ((X :ACCESSOR PT-X :INITARG :X :TYPE REAL :INITFORM 0) + (Y :ACCESSOR PT-Y :INITARG :Y :TYPE REAL :INITFORM 0) + (Z :ACCESSOR PT-Z :INITARG :Z :TYPE REAL :INITFORM 0) + (UUID :READER UUID :INITARG :UUID :TYPE INTEGER :INITFORM + (MAKE-UUID) :DOCUMENTATION "A unique ID")) + (:DOCUMENTATION "A point in real 3d space")) + +See `def:class`'s docstring for details. -- cgit v1.2.3