Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Incidentally, this is why prefix notation seems so foreign. (+ 1 2) reads as "plus one two."

It might just be the Lisp version of Stockholm Syndrome, but it seems perfectly natural to me to gloss that as "Add one and two."



Good point. (eq (+ 1 2) 3) would read "is add one to two equal to three?" though.


One thing that long ago helped me to apprehend and appreciate the power of functional programming was to start thinking descriptively (in terms of facts and propositions) rather than prescriptively (in terms of imperatives and commands).

Thus, I read “(+ 1 2)“ as “the sum of 1 and 2” rather than ”add 1 and 2“. Similarly, I read ”(eq (+ 1 2) 3)“ as ”the difference between 3 and the sum of 1 and 2 is zero“.


"Are the sum of one and two equal to three" is how you'd read that.


Equal would come first for lisp.

"Would you consider equal the sum of 1 and 2 to 3?"


Lisp is read from the middle. (+ 1 2) sort of comes first since it's evaluated first.

Though now that I type that out, I'm acutely aware of how strange it sounds. Interesting.

It's also not true in the case of macros, e.g. let. So, you're right. No wonder it seems so foreign.


Don't use EQ to compare numbers. Use EQL or = .

EQ is object sameness. Number objects of the same value are not necessarily the same object.


"Equality of (sum of 1 and 2) and 3".

It's nice because it shows it's a value not a question.

But I don't really verbalize code, I think in symbols, maybe that's why prefix doesn't bother me.




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

Search: