Path: utzoo!utgpu!water!watmath!clyde!rutgers!labrea!rocky!andy From: andy@rocky.STANFORD.EDU (Andy Freeman) Newsgroups: comp.lang.lisp Subject: Re: Correctness (was Re: Common Lisp lacks portability) Message-ID: <859@rocky.STANFORD.EDU> Date: 17 Dec 87 11:25:12 GMT References: <1421@orstcs.CS.ORST.EDU> <233@spt.entity.com> <2126@ulowell.cs.ulowell.edu> <5208@sol.ARPA> <1547@orstcs.CS.ORST.EDU> Reply-To: andy@rocky.UUCP (Andy Freeman) Organization: Stanford University Computer Science Department Lines: 54 In article <1547@orstcs.CS.ORST.EDU> ruffwork@CS.ORST.EDU (Ritchey Ruff) writes: >I tend to come from a software engineering viewpoint, so I'll make my >bast stab at it - > A correct program is one that - > - has a specification of correct behavour for both > correct *and* *incorrect* input; > - will give the correct output for *ANY* possible input > (using above specifiaction for validation). >This means - > (1) common lisp IS correct (it is following its definition ;-), but > (2) it makes it VERY hard for programmers to write "portable" > correct code because Steele et.al. underspecified the > definition of the language. You are FORCED to either use > a subset of the whole language or validate it on every > CL implementation (and even version) you will run it on. (2) is false. Ruff's program was incorrect by his definition. Others have covered Ruff's misunderstanding of what common lisp declarations are. His (unstated) specification required code that he didn't write; I'll sketch an appropriate PORTABLE defintion. The original program was something like (defun silly (a b) (declare (integer a b)) (loop i from a to b do (print i))) Silly does not handle illegal input - its definition promises that its input is well-formed. Safe-silly handles illegal input. (defun safe-silly (a b)(let ((a a) (b b)) (declare (integer a b)) (loop i from a to b do (print i)))) [Insert some sarcastic comments here.] This is the same sort of thing one must do in every language. For example, one must test input to pascal programs. [I don't feel like explaining this so insert more sarcasm here.] -andy -- Andy Freeman UUCP: {arpa gateways, decwrl, sun, hplabs, rutgers}!sushi.stanford.edu!andy ARPA: andy@sushi.stanford.edu (415) 329-1718/723-3088 home/cubicle