News for hackers. Stuff that matters.
Re:Phrase origin: Why do we "call" functions? by seabass on Wednesday July 09, 2025 @12:49AM (#44506423)
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”?
Re:Phrase origin: Why do we "call" functions? by antod on Wednesday July 09, 2025 @12:55AM (#44506448)
I'm guessing "throw" came about after someone decided to "catch" errors.

As for "raise", maybe exceptions should've been called objections.

Re:Phrase origin: Why do we "call" functions? by zahlman on Wednesday July 09, 2025 @12:08PM (#44511745)

  RuntimeObjection: autopsy report changed contents during cross-examination
Re:Phrase origin: Why do we "call" functions? by maxbond on Wednesday July 09, 2025 @09:36PM (#44516384)
"Exception" comes from hardware/state machines, and the name reflects that they may not be error cases. For instance, if an embedded device is waiting for a button press, then pressing that button will put the MCU into an exceptional/special state (eg interrupting execution or waking up from sleep).

But surely those days are in the past. We should call them objections, because they're always used for errors and never for control flow. [1] After all, that would be an unconditional jump, and we've already settled that those are harmful.

[1] https://docs.python.org/3/library/exceptions.html#StopIterat...

Re:Phrase origin: Why do we "call" functions? by yongjik on Wednesday July 09, 2025 @02:54AM (#44507014)
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++.)
Re:Phrase origin: Why do we "call" functions? by jamesemmott on Wednesday July 09, 2025 @06:37AM (#44508317)
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.'
Re:Phrase origin: Why do we "call" functions? by baq on Wednesday July 09, 2025 @01:43AM (#44506657)
You throw something catchable and if you fail to catch it it’ll break. Unless it’s a steel ball.

You raise flags or issues, which are good descriptions of an exception.

Re:Phrase origin: Why do we "call" functions? by flufluflufluffy on Wednesday July 09, 2025 @01:22AM (#44506568)
I think “raise” comes from the fact that the exception propagates “upward” through the call stack, delegating the handling of it to the next level “up.” “Throw” may have to do with the idea of not knowing what to do/how to handle an error case, so you just throw it away (or throw your hands up in frustration xD). Totally just guessing
Re:Phrase origin: Why do we "call" functions? by owlbite on Wednesday July 09, 2025 @01:32AM (#44506618)
I suspect it comes from raising flags/signals (literally as one might run a flag up a flag pole?) to indicates CPU conditions, and then that terminology getting propagated from hw to sw.
Re:Phrase origin: Why do we "call" functions? by Findecanor on Wednesday July 09, 2025 @02:35AM (#44506923)
Sounds plausuble. Some of the earliest exception handling systems did not have any semantic difference between CPU exceptions and software exceptions.
Re:Phrase origin: Why do we "call" functions? by devnullbrain on Wednesday July 09, 2025 @10:59AM (#44510825)
You can still use SIGUSR1 and SIGUSR2 for it.
Re:Phrase origin: Why do we "call" functions? by comex on Wednesday July 09, 2025 @01:47AM (#44506683)
I would have thought it came from the concept of 'raising an issue' or even 'raising a stink'.
Re:Phrase origin: Why do we "call" functions? by reverendsteveii on Wednesday July 09, 2025 @01:18PM (#44512594)
idk because there are some circles in which boolean variables are called flags but I've never seen them referred to as being raised or unraised/lowered, only set and unset
Re:Phrase origin: Why do we "call" functions? by kps on Thursday July 10, 2025 @02:26PM (#44524014)
… which could come from raising the voltage of a signal indicating a condition.
Re:Phrase origin: Why do we "call" functions? by titanomachy on Wednesday July 09, 2025 @01:02AM (#44506467)
That's a great question. The first language I learned was python, and "for i in range(10)" makes a lot of sense to me. But "for (int i = 0; i < 10; i++)" must have come first, and in that case "for" is a less obvious choice.
Re:Phrase origin: Why do we "call" functions? by Dwedit on Wednesday July 09, 2025 @01:11AM (#44506505)
BASIC had the FOR-NEXT loop back in 1964.

10 FOR N = 1 TO 10

20 PRINT " ";

30 NEXT N

C language would first release in 1972, that had the three-part `for` with assignment, condition, and increment parts.

Re:Phrase origin: Why do we "call" functions? by kahirsch on Wednesday July 09, 2025 @02:44AM (#44506971)
This reminds me of a little bit of trivia. In very old versions of BASIC, "FORD=STOP" would be parsed as "FOR D = S TO P".

I found that amusing circa 1975.

Re:Phrase origin: Why do we "call" functions? by zabzonk on Wednesday July 09, 2025 @01:18AM (#44506544)
In Fortran, it is a do-loop :)
Re:Phrase origin: Why do we "call" functions? by bee_rider on Wednesday July 09, 2025 @01:41AM (#44506646)
Fortran has grown a lot over time. If somebody said it don’t have a do loop in 196X, I wouldn’t be too surprised.

Really it’s just syntactic sugar, just use a goto.

Re:Phrase origin: Why do we "call" functions? by pklausler on Wednesday July 09, 2025 @02:38AM (#44506939)
The entire point of Fortran was being an effective optimizing compiler for DO loops.
Re:Phrase origin: Why do we "call" functions? by bregma on Wednesday July 09, 2025 @12:23PM (#44511900)
FORTRAN IV, at least the version I used on the PDP-11 running RSX, did not have a DO-loop. Just IF and GO TO. But it did have both logical and arithmetic IF.
Re:Phrase origin: Why do we "call" functions? by pklausler on Wednesday July 09, 2025 @06:49PM (#44515503)
I don’t believe this.
Re:Phrase origin: Why do we "call" functions? by masklinn on Wednesday July 09, 2025 @01:16AM (#44506536)
FOR comes from ALGOL in which as far as I know is was spelled:

    for p := x step d until n do
Re:Phrase origin: Why do we "call" functions? by QuesnayJr on Wednesday July 09, 2025 @01:29AM (#44506602)
Algol 58 had "for i:=0(1)9". C's for loop is a more general variant.
Re:Phrase origin: Why do we "call" functions? by gmueckl on Wednesday July 09, 2025 @02:38AM (#44506943)
"For" for loop statements fits with math jargon: "for every integer i in the set [1:20], ..."
Re:Phrase origin: Why do we "call" functions? by pansa2 on Wednesday July 09, 2025 @02:11AM (#44506785)
“for” is short for “for each”, presumably. `for i in 1..=10` is short for “for each integer i in the range 1 to 10”.
Re:Phrase origin: Why do we "call" functions? by cb321 on Wednesday July 09, 2025 @08:12PM (#44515987)
Yeppers. For a few more details, one might start here: https://en.wikipedia.org/wiki/Universal_quantification