tag:blogger.com,1999:blog-6508797467947601724.post6170791459359150344..comments2023-09-16T11:35:50.154-04:00Comments on smuglispweeny: Tilton's Law of Programming: Fear No EvilKenny Tiltonhttp://www.blogger.com/profile/17430816457662806163noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-6508797467947601724.post-15211725051113595952008-07-10T17:48:00.000-04:002008-07-10T17:48:00.000-04:00My own personal rule on this is to use functional ...My own personal rule on this is to use functional programming whenever possible and let the GC deal with it. This eliminates all potential for a whole class of bugs. The only time I won't do that is when it's just <B>so</B> dead obvious that I own the list structure in the particular function I'm writing (like the function is building it cons by cons using push with a possible nreverse).<BR/><BR/>The thing is, even if you make sure your destructive operations are working right the first time, if you're playing around with some hairy corner of the CLHS then you're probably asking for trouble when you next go in and touch that function. At a minimum, leave yourself a good comment telling yourself what you were doing and where the limits are.<BR/><BR/>If I later find that I have produced some pig-slow piece of crap code, I'll go in and optimize. Typically, my biggest optimizations are in not doing something completely retarded with my algorithm as opposed to need to use nconc rather than append.Dave Robertshttps://www.blogger.com/profile/17827695623365385071noreply@blogger.comtag:blogger.com,1999:blog-6508797467947601724.post-76159280505128655492008-05-27T04:31:00.000-04:002008-05-27T04:31:00.000-04:00Well I've decided to dive in. No fear, right?I'll ...Well I've decided to dive in. No fear, right?<BR/><BR/>I'll be checking this space often while I make my own contributions <BR/>here:<BR/><BR/>http://dihymo.blogspot.com/ and on c.l.l.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6508797467947601724.post-32815359425561805992008-04-17T08:53:00.000-04:002008-04-17T08:53:00.000-04:00Just was pointed at your blog, excellent stories. ...Just was pointed at your blog, excellent stories. It struck me that this particular item shows the equivalent of classic Objective-C memory management (which uses retain counts); it's a common newbie mistake regarding object ownership.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6508797467947601724.post-44738448836901340742008-03-14T12:19:00.000-04:002008-03-14T12:19:00.000-04:00Doesn't this mistake Anonymous pointed out show ex...<I>Doesn't this mistake Anonymous pointed out show exactly why one shoudn't use the destructive functions without a good reason?</I><BR/><BR/>No, the title still holds: "Fear No Evil". The standard is perfectly clear, so there is no ambiguity, I just screwed up because I had been programming Lisp for years without realizing remove does not always copy. (Makes me wonder why I never got bit. Anyway...) But I did happen to read that append does not copy the last list, so I am not all bad. The Right Answer is to learn more, not fear more.<BR/><BR/>The thing is, we need to learn this stuff anyway because we simply cannot get away with never using destructive functions -- noobs are forever writing dead slow stuff even on simple exercises because they get into a combinatorial explosion of consing by having unnecessary non-destructive calls in a heavy-hitter location. <BR/><BR/>And since we have to learn anyway, we may as well use the right function. Not sure? Look it up. The CLHS is real handy that way.Kenny Tiltonhttps://www.blogger.com/profile/17430816457662806163noreply@blogger.comtag:blogger.com,1999:blog-6508797467947601724.post-8075209395362847132008-03-14T11:38:00.000-04:002008-03-14T11:38:00.000-04:00Doesn't this mistake Anonymous pointed out show ex...Doesn't this mistake Anonymous pointed out show exactly why one shoudn't use the destructive functions without a good reason? <BR/>Using destructive updates forces you to think about this 'ownership' thing, while that could be completely ignored if you used only the nondestructive functions. One less unnecessary detail to think about and potential bug to resolve. nconc & co should be used as performance optimizations only.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6508797467947601724.post-7367587377142367532008-03-11T04:46:00.000-04:002008-03-11T04:46:00.000-04:00According to the hyperspec, remove-if-not can retu...<I>According to the hyperspec, remove-if-not can return the list unchanged.</I><BR/><BR/>PWUAHAHAHAHAHAA! Does anyone remember a similar sequence in which some guy publicly tried to write a decent C++ "copy" constructor or something leading to this just enormous thread of amendments and refinements and gotcha fixes, the best part being he had started out with, "Look, this is easy..."?<BR/><BR/>I'll be honest, I have seen that cautionary note about remove-if-not or maybe it was something else and (a) been aghast but (b) never internalized it, I must have time bombs sitting out there waiting to go off.<BR/><BR/>Oh, well. Once more into the breach!...Kenny Tiltonhttps://www.blogger.com/profile/17430816457662806163noreply@blogger.comtag:blogger.com,1999:blog-6508797467947601724.post-21695595734628436962008-03-11T04:28:00.000-04:002008-03-11T04:28:00.000-04:00According to the hyperspec, remove-if-not can retu...According to the hyperspec, remove-if-not can return the list unchanged. Thus, if no element is removed, it would not be safe to pass tmp to map-into.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6508797467947601724.post-32296731477826089822008-03-09T17:15:00.000-04:002008-03-09T17:15:00.000-04:00Nice rant. Paul Graham has written something very...Nice rant. Paul Graham has written something very similar about who owns what, in <I>On Lisp</I>:<BR/><BR/>"Who owns arguments and return values? The convention in Lisp seems to be that an invocation owns objects it receives as return values, but not objects passed to it as arguments."<BR/><BR/>Also, thanks for the c.l.l pointer to the newbie guidelines. Some of them are idiosyncratic, as you observe. This one struck me: "Use complex numbers to represent points in a plane." Okay, even if I've come across commercial systems that don't do this...Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6508797467947601724.post-36097241268569176952008-03-09T16:44:00.000-04:002008-03-09T16:44:00.000-04:00Hi,I very much enjoyed reading this post and I esp...Hi,<BR/><BR/>I very much enjoyed reading this post and I especially liked this line "Technology is like an ill-tempered dog: never show it fear."<BR/><BR/>Hopefully, SLIME debugger will help me in showing no fear:)srdjanhttps://www.blogger.com/profile/10092873623666157195noreply@blogger.com