措辞问题 [英] Question on Wording

查看:61
本文介绍了措辞问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我正在努力详细了解C

用于教学目的的正确措辞。

例如:

int foo(int x,int y){

int k;

...

返回k;

}


你可以调用foo函数或程序。关于这个问题,我猜

选择是函数(K& R2和C99标准),因为那里没有

出现的单词程序可以告诉。不过,

很不幸,因为你需要解释这些函数不是数学意义上的等等,但这不是一个大问题。 />

另一方面,你怎么称呼x?这是一个参数还是一个参数?

K& R2似乎提到这两个词,我无法发现差异。那么
会假设int x,int y是参数列表/参数

根据x和y列出的列表。但是使用哪种措辞?


此外,我提出了函数定义。函数

声明将是:

int foo(int x,int y);


但是,如果我出现怎么办?函数定义,并且只想在函数体之前的部分引用
(复合语句到目前为止,对于C99而言是
)?我应该把它称为函数声明(似乎

因为我已经使用了上面的函数声明而不明确)或函数

header(这可能会导致与头文件混淆)。


我很感激这方面的投入。


最好的问候,


-

Paulo Jorge Matos - potm at soton.ac.uk
http://www.personal.soton.ac.uk/pocm

博士生@ ECS

英国南安普顿大学

解决方案

Paulo Jorge de OC de Matos写道:


大家好,


我试图详细了解C

用于教学目的的正确措辞。

例如:

int foo(int x,int y){

int k;

...

返回k;

}


你可以称之为foo功能离子或程序。关于这个问题,我猜

选择是函数(K& R2和C99标准),因为那里没有

出现的单词程序可以告诉。不过,

很不幸,因为你需要解释这些函数不是数学意义上的等等,但这不是一个大问题。 />

另一方面,你怎么称呼x?是参数还是

参数? K& R2似乎提到了这两个词,我无法发现

的差异。然后我假设int x,int y是参数

list / parameter

根据x和y列出的列表。但是使用哪种措辞?



我会在

中使用实际表达式的单词参数调用函数的括号,并使用word参数来

在函数声明中指定相同的内容。


< http://en.wikipedia.org/wiki/Parameter_%28computer_science%29>


另一种选择是使用形式参数。和实际参数但对于快速沟通来说,这很麻烦。


此外,我提出了函数定义。函数

声明将是:

int foo(int x,int y);


但是,如果我出现怎么办?函数定义,并且只想在函数体之前的部分引用
(复合语句到目前为止,对于C99而言是
)?我应该把它称为函数声明(似乎

因为我已经使用了上面的函数声明而模糊不清)或函数

header(这个可能会与头文件混淆)。



这是一个语法错误,它提供了一个函数定义,没有它'

相关的大括号对或者提供一个函数声明而没有

它是终止分号,我建议你总是使用它们:


T foo(T param){}





T foo(T param);


在演示示例时。如果你确实想使用它的名字,那么

函数头似乎最适合我。也许其他人会

建议更正确或更好的东西。


Paulo Jorge de OC de Matos写道:


Hello all,


我想详细了解在C

中使用的正确措辞教学目的。

例如:

int foo(int x,int y){

int k;

...

返回k;

}


你可以调用foo函数或程序。关于这个问题,我猜

选择是函数(K& R2和C99标准),因为那里没有

出现的单词程序可以告诉。不过,

很不幸,因为你需要解释这些函数不是数学意义上的等等,但这不是一个大问题。 />

另一方面,你怎么称呼x?这是一个参数还是一个参数?

K& R2似乎提到这两个词,我无法发现差异。那么
会假设int x,int y是参数列表/参数

根据x和y列出的列表。但是使用哪种措辞?



参数或形式参数或形式参数。是'x''和'y''。

参数是来电者提供的价值。


...但并非所有发言人和作家都小心地将这两者区分开来,所以这些条款经常是(错误地使用,就好像他们的b $ b意味着同样的事情。当我们说strlen()的参数是一个字符串时,它就是那种松散的语言

。或者

"是指向字符串的指针;"调用

它是更精确的指向字符串的第一个字符的指针。但是为了保持正确性,它会更加繁琐。


此外,我提出了函数定义。函数

声明将是:

int foo(int x,int y);



或者只是`int foo(int,int);''。并且为了追求精确度

,可能会注意到`;''不是

声明的一部分。例如,考虑


int foo(int,int),bar(double),baz(int,const char *);


....我通常不会使用的样式,但这是合法的。


但是,如果我提出函数定义并且只想引用

到函数体之前的部分(复合语句到目前为止,对于C99而言是
)?我应该把它称为函数声明(似乎

因为我已经使用了上面的函数声明而模糊不清)或函数

header(这个可能会与头文件混淆)。



我不知道提供什么建议。

的正式语法语言没有定义一个包含所有

的符号,只有定义的那部分,所以标准不是

帮助提出一个合适的名字。您的

需要将此部分称为准独立单元,而不是函数定义的介绍部分,而不是
?我猜b $ b猜测前导码如果一个人必须找到
,那就好了。


我会避免声明和标题因为你提到了b $ b b bb的原因,也因为在旧式函数定义中

这部分可以*包含*声明:


int foo(x,y)

int x; / *声明* /

int y; / *声明* /

{...}

-

Eric Sosman
es ***** @ ieee-dot-org.inva 盖子


Paulo Jorge de OC de Matos说:


大家好,


我想详细了解正确的措辞用于教学目的。

例如:

int foo(int x,int y){

int k;

...

返回k;

}


你可以调用foo函数或程序。在这个问题上,我猜

选择是功能(K& R2和C99标准)



对。这不仅仅是K& R / C99术语 - 它也是一般的C程序员

术语。我从来没有听说过真正的C程序员。 (cfTrue

苏格兰人)称之为程序。


另一方面,你称之为x?它是参数还是参数?这是一个参数。

b $ b rc = function(argument_expressions_are_what_you_pass);


这是一个参数:


int function(char * parameters_are_what_the_function_receives)


想想一扇门。在这一方面画上了论据。打开它,一步一步,

并关闭它。另一方面,您将看到参数 (大,

友好信件)。请注意,您现在是自己的副本。


此外,我提供了函数定义。函数

声明将是:

int foo(int x,int y);


但是,如果我出现怎么办?函数定义,并且只想在函数体之前的部分引用
(复合语句到目前为止,对于C99而言是
)?



它被称为函数声明者。


-

Richard Heathfield< http://www.cpax.org.uk>

电子邮件:-http:// www。 + rjh @

谷歌用户:< http://www.cpax.org.uk/prg/writings/googly.php>

Usenet是一个奇怪的放置" - dmr 1999年7月29日


Hello all,

I am trying to understand in detail the correct wording to use in C
for teaching purposes.
For the example:
int foo(int x, int y) {
int k;
...
return k;
}

you could call foo a function or a procedure. On this matter I guess
that the choice is function (K&R2 and C99 standard) given there''s no
occurrences of the word procedure there as far as I can tell. Still,
it is unfortunate because you need to explain that these functions are
not in the mathematical sense and so on but it''s not a huge issue.

On the other hand, what do you call x? Is it an argument or a parameter?
K&R2 seems to mention both words and I couldn''t spot the difference. I
would then assume that "int x, int y" is the argument list/ parameter
list according to what x and y are. But which wording to use?

Moreover, I presented the function definition. The function
declaration would be:
int foo(int x, int y);

but, what if I present the function definition and want to refer only
to the part before the body of the function (compound statement as far
as C99 is concerned)? Shall I call it function declaration (seems
ambiguous since I already used function declaration above) or function
header (this one might create confusion with header files).

I would appreciate input on this.

Best Regards,

--
Paulo Jorge Matos - pocm at soton.ac.uk
http://www.personal.soton.ac.uk/pocm
PhD Student @ ECS
University of Southampton, UK

解决方案

Paulo Jorge de O. C. de Matos wrote:

Hello all,

I am trying to understand in detail the correct wording to use in C
for teaching purposes.
For the example:
int foo(int x, int y) {
int k;
...
return k;
}

you could call foo a function or a procedure. On this matter I guess
that the choice is function (K&R2 and C99 standard) given there''s no
occurrences of the word procedure there as far as I can tell. Still,
it is unfortunate because you need to explain that these functions are
not in the mathematical sense and so on but it''s not a huge issue.

On the other hand, what do you call x? Is it an argument or a
parameter? K&R2 seems to mention both words and I couldn''t spot the
difference. I would then assume that "int x, int y" is the argument
list/ parameter
list according to what x and y are. But which wording to use?

I would use the word arguments for the actual expressions used within
the parenthesis in a call to a function and use the word parameter to
designate the same in a function declaration.

<http://en.wikipedia.org/wiki/Parameter_%28computer_science%29>

An alternative is use "formal parameter" and "actual parameter" but
that''s cumbersome for quick communication.

Moreover, I presented the function definition. The function
declaration would be:
int foo(int x, int y);

but, what if I present the function definition and want to refer only
to the part before the body of the function (compound statement as far
as C99 is concerned)? Shall I call it function declaration (seems
ambiguous since I already used function declaration above) or function
header (this one might create confusion with header files).

It''s a syntax error to present a function definition without it''s
associated brace pairs or to present a function declaration without
it''s terminating semicolon, there I suggest that you always use either:

T foo(T param) {}

or

T foo(T param);

when presenting examples. If you do want to use a name for it, then
function header seems the most suitable to me. Maybe someone else will
suggest something more correct or better.


Paulo Jorge de O. C. de Matos wrote:

Hello all,

I am trying to understand in detail the correct wording to use in C
for teaching purposes.
For the example:
int foo(int x, int y) {
int k;
...
return k;
}

you could call foo a function or a procedure. On this matter I guess
that the choice is function (K&R2 and C99 standard) given there''s no
occurrences of the word procedure there as far as I can tell. Still,
it is unfortunate because you need to explain that these functions are
not in the mathematical sense and so on but it''s not a huge issue.

On the other hand, what do you call x? Is it an argument or a parameter?
K&R2 seems to mention both words and I couldn''t spot the difference. I
would then assume that "int x, int y" is the argument list/ parameter
list according to what x and y are. But which wording to use?

The "parameters" or "formal parameters" are `x'' and `y''.
The "arguments" are the values provided by the caller.

... but not all speakers and writers are careful to make
the distinction, so the terms are often (mis)used as if they
meant the same thing. It''s the same kind of loose language
as when we say "The argument to strlen() is a string" or
"is a pointer to a string;" it would be more precise to call
it "a pointer to the first char of a string," but it would
also be more tedious to maintain the exactness.

Moreover, I presented the function definition. The function
declaration would be:
int foo(int x, int y);

Or just `int foo(int, int);''. And in pursuit of precision
it might be well to note that the `;'' is not part of the
declaration. For example, consider

int foo(int, int), bar(double), baz(int, const char*);

.... a style I would not ordinarily use, but which is legal.

but, what if I present the function definition and want to refer only
to the part before the body of the function (compound statement as far
as C99 is concerned)? Shall I call it function declaration (seems
ambiguous since I already used function declaration above) or function
header (this one might create confusion with header files).

I don''t know what advice to offer. The formal grammar of
the language does not define one symbol that encompasses all
and only that part of the definition, so the Standard is no
help in coming up with a suitable name. How pressing is your
need to refer to this part as a quasi-independent unit, rather
than as the introductory part of the function definition? I
guess "preamble" would be as good a word as any, if one must
be found.

I''d avoid "declaration" and "header" for the reasons you
mention, and also because in an old-style function definition
this part can *contain* declarations:

int foo(x, y)
int x; /* declaration */
int y; /* declaration */
{ ... }

--
Eric Sosman
es*****@ieee-dot-org.invalid


Paulo Jorge de O. C. de Matos said:

Hello all,

I am trying to understand in detail the correct wording to use in C
for teaching purposes.
For the example:
int foo(int x, int y) {
int k;
...
return k;
}

you could call foo a function or a procedure. On this matter I guess
that the choice is function (K&R2 and C99 standard)

Right. That isn''t just K&R/C99 terminology - it''s general C programmer
terminology too. I''ve never heard a "real C programmer" (cf "True
Scotsman") call it a procedure.

On the other hand, what do you call x? Is it an argument or a parameter?

It''s a parameter.

Here''s an argument:

rc = function(argument_expressions_are_what_you_pass);

Here''s a parameter:

int function(char *parameters_are_what_the_function_receives)

Think of a door. On this side is painted "argument". Open it, step through,
and close it. On the other side, you will see "parameter" (in large,
friendly letters). Note that you are now a copy of yourself.

Moreover, I presented the function definition. The function
declaration would be:
int foo(int x, int y);

but, what if I present the function definition and want to refer only
to the part before the body of the function (compound statement as far
as C99 is concerned)?

It''s called a "function declarator".

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999


这篇关于措辞问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆