←back to thread

173 points todsacerdoti | 2 comments | | HN request time: 0.407s | source
Show context
seabass ◴[] No.44506423[source]
I love this sort of cs history. I’m also curious—why do we “throw” an error or “raise” an exception? Why did the for loop use “for” instead of, say, “loop”?
replies(7): >>44506448 #>>44506467 #>>44506568 #>>44506657 #>>44506785 #>>44506943 #>>44507014 #
1. yongjik ◴[] No.44507014[source]
It's been ages, but I think an earlier edition of Stroustrup's The C++ Programming Language explains that he specifically chose "throw" and "catch" because more obvious choices like "signal" were already taken by established C programs and choosing "unusual" words (like "throw" and "catch") reduced chance of collision. (C interoperability was a pretty big selling point in the early days of C++.)
replies(1): >>44508317 #
2. jamesemmott ◴[] No.44508317[source]
The design of exception handling in C++ was inspired by ML, which used 'raise', and C++ might itself have used that word, were it not already the name of a function in the C standard library (as was 'signal'). The words 'throw' and 'catch' were introduced by Maclisp, which is how Stroustrup came to know of them. As he told Guy Steele at the second ACM History of Programming Languages (HOPL) conference in 1993, 'I also think I knew whatever names had been used in just about any language with exceptions, and "throw" and "catch" just were the ones I liked best.'