Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!pacbell.com!decwrl!hayes.fai.alaska.edu!accuvax.nwu.edu!mmdf From: lynch@aristotle.ils.nwu.edu (Richard Lynch) Newsgroups: comp.lang.lisp Subject: Matching Parens (was Virtues of LISP Syntax?) Message-ID: <12558@accuvax.nwu.edu> Date: 25 Sep 90 22:15:43 GMT Sender: mmdf@accuvax.nwu.edu Lines: 61 I can read LISP code just fine if "standard" parenthesis rules are used. BUT, when it comes to debugging code known to be faulty, I really hate to try and figure out which parenthesis the ones at the end of a line are coding. And it's not enough to assume that the code is lined up correctly (even by the editors that supposedly line it up for you.) That's why I always follow these rules: A closing parenthesis can only appear: A. In the same line as the open parenthesis. B. In the same column as the open parenthesis. The indentation for arguments on lines below the function is 2 spaces. Always. Thus, my code looks like this: (defun insert-menu (menu &optional (place nil)) "Inserts menu at place in the menubar. If place is a menu, the new menu goes after it. If place is an integer, the menu goes in that ordinal position." (let ((need-update (installed-p))) (if place (let* ((old-menus (menus)) (len (length old-menus)) ) (when (isa-p place *menu*) (let ((pos (position place old-menus))) (if pos (setq place (1+ pos)) (setq place (1+ len)) ) ) ) (if (integerp place) (progn (setq place (max 0 place)) (setq place (min place (1+ len))) (if (= place (1+ len)) (add-menu menu) (set-menus (nconc (subseq old-menus 0 place) (list menu) (subseq old-menus place len) ) ) ) ) (cerror "Adding ~S to end of menubar..." "Invalid place specifier ~S for insert-menu.~%~ place must be an integer or menu." place (add-menu menu) ) ) ) (add-menu menu) ) (if need-update (set-menubar (menus))) ) ) Actually, before you flame me, I am aware that on lines that have just right parens, they are in reverse order and thus my rules are incorrectly stated. But I consider them "isomorphic" in some sense. I hardly ever have parenthesis problems, and when I do, I find the error very quickly. The expense of a lot of lines with just right parens is worth the benifit of minimal debugging time to me. Anyone else use this, or am I all alone here? "TANSTAAFL" Rich lynch@aristotle.ils.nwu.edu