subroutine
/ˈsʌbruːtiːn/ (bre, ipa) · /ˈsʌbruːtiːn/ (ame, ipa) · /ˈsəb-(ˌ)rü-ˌtēn/ (ame, mw)
subroutine — 名詞
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.
Asher 寫了一個副程式,用來從每日氣溫清單中計算平均溫度。
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.
處理使用者登入的副程式出了問題,所以 Salma 修改並重新測試了它。
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.
Arjun 將主程式拆成十個較小的副程式,以簡化除錯工作。
- 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.