Hacker News new | past | comments | ask | show | jobs | submit login

> Foo and FOO and |FOO| are the same symbol

No, they aren't. The strings "Foo" and "FOO" and "|FOO|" might be read by the reader as the same symbol, but then again, they might not. It depends on a great many things.

By default, all else being equal, yes, reading these three strings will produce the same symbol. But there are any number of factors that can change this.

    Clozure Common Lisp Version 1.12.1 (v1.12.1-10-gca107b94) DarwinX8664
    ? (setf x 'foo)
    FOO
    
    [Stuff elided]
    
    ? (eq x 'foo)
    NIL
    
    [More stuff elided]
    
    ? (EQ 'foo 'FOO)
    NIL
Figuring out what I left out is left as an (elementary) exercise (though the fact that I had to type EQ instead of eq in the last line is a big clue).

And I know that you know this. My point is not that you don't understand symbols or name spaces; I know you do. My point is that explaining this stuff is hard, and very few people seem to be willing to put in the effort. And this is not unique to CL, and it's not even unique to software, or even to STEM. It seems to be endemic in the human condition. But that doesn't mean one should not lament it or try to improve it.




It's probably not necessary to mention that the treatment of case and whatnot is default behavior. That can be covered in an advanced chapter about read tables. There we can say, oh we lied when we said that foo, FOO and |FOO| read the same; this is actually highly programmable.

The student will not encounter that unless they explore someone else's code, or discover the features like readtable-case and experiment.

Just talking about the default behavior, if it is stable and portable, and doesn't mysteriously flip behind your back, is fine.


Even if you leave case out of it, it is not true that Foo and FOO are necessarily the same symbol, or even that FOO and FOO are necessarily the same symbol. In fact, the whole point of packages is that you can have two different symbols with the same name.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: