<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Dom λ Blog - Latest Comments</title><link>http://domblog.disqus.com/</link><description></description><atom:link href="https://domblog.disqus.com/comments.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Wed, 09 Feb 2011 00:52:11 -0000</lastBuildDate><item><title>Re: Lesson learned: never modify literals, quote lists only for constant data</title><link>http://domdefelice.com/blog/2011/02/never-modify-literal-objects/#comment-143216283</link><description>&lt;p&gt;Yes.. usually I use eq just for symbols comparison. To be sure that two lists are the same (aka same elements, even if different instances) better to use equal&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dom De Felice</dc:creator><pubDate>Wed, 09 Feb 2011 00:52:11 -0000</pubDate></item><item><title>Re: Lesson learned: never modify literals, quote lists only for constant data</title><link>http://domdefelice.com/blog/2011/02/never-modify-literal-objects/#comment-143214388</link><description>&lt;p&gt;Yes, modifying destructively a literal object has always undefined consequences. It is defined by the language specs themselves. Every lisp compiler could have a different behaviour.&lt;br&gt;For a literal object to be modified as a data structure it is always better to copy it as it was a "shape" with copy-list or copy-tree and then work on it :-)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dom De Felice</dc:creator><pubDate>Wed, 09 Feb 2011 00:47:09 -0000</pubDate></item><item><title>Re: Lesson learned: never modify literals, quote lists only for constant data</title><link>http://domdefelice.com/blog/2011/02/never-modify-literal-objects/#comment-142857697</link><description>&lt;p&gt;Another important problem with that stuff is the eq problem...&lt;/p&gt;&lt;p&gt;Well truing to imagine a compiled implementation of our quote :&lt;/p&gt;&lt;p&gt;static CONS quote1 = list(symbol("a"), symbol("b"), symbol("c"));&lt;br&gt;...&lt;br&gt;return SETQ( symbol("a"), quote1);&lt;/p&gt;&lt;p&gt;in the case of (setq a '(a b c))&lt;/p&gt;&lt;p&gt;We could change for changing the initialisation :&lt;/p&gt;&lt;p&gt;return SETQ( symbol("a"), list(symbol("a"), symbol("b"), symbol("c")));&lt;/p&gt;&lt;p&gt;but as pointer out by λ, list is not the same as quote... returned value is eq in the first case, not in the second as it's another instance of a cons if function is called more than once... And I know symbol("a") has no meaning except render back the original lisp sentence... ;)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Aloys Lisp</dc:creator><pubDate>Tue, 08 Feb 2011 15:46:31 -0000</pubDate></item><item><title>Re: Lesson learned: never modify literals, quote lists only for constant data</title><link>http://domdefelice.com/blog/2011/02/never-modify-literal-objects/#comment-142836151</link><description>&lt;p&gt;Just one link, saying the same thing : &lt;a href="http://www.lispforum.com/viewtopic.php?f=2&amp;amp;t=1064" rel="nofollow noopener" target="_blank" title="http://www.lispforum.com/viewtopic.php?f=2&amp;amp;t=1064"&gt;http://www.lispforum.com/vi...&lt;/a&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Aloys Lisp</dc:creator><pubDate>Tue, 08 Feb 2011 15:13:00 -0000</pubDate></item><item><title>Re: Lesson learned: never modify literals, quote lists only for constant data</title><link>http://domdefelice.com/blog/2011/02/never-modify-literal-objects/#comment-142546616</link><description>&lt;p&gt;In fact as you point out, the quoted thing is in your code and if you modify it you modify your code.&lt;/p&gt;&lt;p&gt;The result is impredictable means that it depends if the litteral stuff is put in a protected place.&lt;/p&gt;&lt;p&gt;In c you put :&lt;/p&gt;&lt;p&gt;char *text = "blah blah";&lt;/p&gt;&lt;p&gt;You perfectly have the right to write into your string... :D. But if you launch the program again, constant string is initialized back. If you rerun (w/o loading) your program in lisp and you can change your litterals, it will be in the last modification state...&lt;/p&gt;&lt;p&gt;If your code is compiled... interesting question. As quote is a special operator it will will be 'specialy' processed... good thing to think about...&lt;/p&gt;&lt;p&gt;In fact you cannot mark cons as litteral :&lt;br&gt;(setq a '(a b c))&lt;br&gt;(setq b (cdr a))&lt;br&gt;(rplaca b 'r)&lt;/p&gt;&lt;p&gt;mhhhh ? taking the pointers, that's always code that's changed, juste the second element of the list...&lt;/p&gt;&lt;p&gt;Funny, I didn't pointed it out.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Aloys Lisp</dc:creator><pubDate>Tue, 08 Feb 2011 08:02:41 -0000</pubDate></item><item><title>Re: Lesson learned: never modify literals, quote lists only for constant data</title><link>http://domdefelice.com/blog/2011/02/never-modify-literal-objects/#comment-141542541</link><description>&lt;p&gt;Corrected. Thanks for reporting. :-)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dom De Felice</dc:creator><pubDate>Sun, 06 Feb 2011 06:46:45 -0000</pubDate></item><item><title>Re: Lesson learned: never modify literals, quote lists only for constant data</title><link>http://domdefelice.com/blog/2011/02/never-modify-literal-objects/#comment-141541410</link><description>&lt;p&gt;(quote foo bar baz) is wrong. QUOTE takes only one form, not three.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Foo</dc:creator><pubDate>Sun, 06 Feb 2011 06:37:19 -0000</pubDate></item></channel></rss>