subroutine
/ˈsʌbruːtiːn/ (bre, ipa) · /ˈsʌbruːtiːn/ (ame, ipa) · /ˈsəb-(ˌ)rü-ˌtēn/ (ame, mw)
subroutine — noun
1. a named block of computer code within a program that carries out one specific ta
a named block of computer code within a program that carries out one specific task and can be used repeatedly whenever that task is needed — for example, a subroutine that calculates a total, checks a password, or draws a shape on the screen.
Asher wrote a subroutine to calculate the average temperature from daily readings.
subroutine + to-infinitive for purpose
When the game checks a score, it calls the same subroutine instead of repeating code.
call a subroutine — most common verb collocation
The subroutine that handles user log-in had a bug, so Salma fixed and retested it.
At startup the program loads several subroutines into memory for later use.
Arjun split the main program into ten smaller subroutines to make debugging easier.
- function
the most common modern term; a function usually returns a value, while a subroutine in older terminology does not.
- procedure
used especially in Pascal and SQL; focuses on the sequence of steps rather than the code block itself.
- method
object-oriented term for a subroutine that belongs to a class.
- routine
shorter, general term; can refer to any set of coded instructions.
文法句型
subroutine + that-clause
call/invoke/define + subroutine
用法筆記
Frequently used with the verbs call, invoke, define, run, and return from. In modern programming languages, subroutines are often called functions or methods, depending on the language paradigm.