“功能”与“功能”之间的区别是什么?和“程序”? [英] What is the difference between a "function" and a "procedure"?
问题描述
所以,我的问题是:
它们在功能,目的和用途方面有什么不同?
<
一个函数返回一个值,一个过程只是执行命令。 b
$ b
名称函数来自数学。它用于根据输入计算一个值。
一个过程是一组可以按顺序执行的命令。
在大多数编程语言中,偶函数可以有一组命令。因此,差异仅在于返回值部分。
但是如果你想保持一个函数的干净,(只要看看函数式语言),就需要确保一个函数没有副作用。 >
Generally speaking, we all hear about the functions or procedures in programming languages. However, I just found out that I use these terms almost interchangeably (which is probably very wrong).
So, my question is:
What is the difference in terms of their functionality, their purpose and use?
An example would be appreciated.
A function returns a value and a procedure just executes commands.
The name function comes from math. It is used to calculate a value based on input.
A procedure is a set of command which can be executed in order.
In most programming languages, even functions can have a set of commands. Hence the difference is only in the returning a value part.
But if you like to keep a function clean, (just look at functional languages), you need to make sure a function does not have a side effect.
这篇关于“功能”与“功能”之间的区别是什么?和“程序”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!