0

我收到一条评论,说调用参数数量不正确的函数是语义错误。我会说它是一个语法错误,因为正确的语法是使用分隔符提供尽可能多的参数。

还有一个问题:如果程序员没有正确理解需求并实现了与请求不同的功能,那是逻辑错误吗?它是否被认为是一个错误?

4

2 回答 2

2

A syntax error has to do only with conformance to the language.

A semantic error has to do with conformance to the API.

A function call that has the wrong number of parameters for the defined function is a semantic error.

As to your second question, at least by my definition, a logic error is when the code compiles and runs but does not function as expected, so I would call your example a logic error. But I'm not sure this definition is universally accepted or obvious, so it may be a matter of opinion.

于 2012-08-31T11:16:09.587 回答
0

方法调用的参数数量不正确是语法错误。如果程序不这样做,客户期望也是一个错误。请求阶段的错误被触发到代码阶段。

于 2012-08-31T11:17:49.150 回答