何时使用替代参数布局? [英] When to use alternative argument layout?

查看:60
本文介绍了何时使用替代参数布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经读过正常和正常类似Java的函数定义,

,例如: int main(int argc,char ** argv),你也可以选择使用

替代语法,即


int main(argc,argv)

int argc; char ** argv;

{

....

}


我''一直在努力想到这种情况,这种替代形式比通常的形式更具表现力,但我想我只是没有

足够富有想象力:)


人们什么时候喜欢替代方式,为什么?

解决方案

Fr ************ @ googlemail.com 写道:


我已经读过正常和正常类似Java的函数定义,

,例如: int main(int argc,char ** argv),你也可以选择使用

替代语法,即



'''没有Java喜欢它们,它们是标准的C.


int main(argc,argv)

int argc; char ** argv;

{

....

}


我''一直在努力想到这种情况,这种替代形式比通常的形式更具表现力,但我想我只是没有

足够富有想象力:)


人们什么时候更喜欢替代方式,为什么?



从来没有,这是一个过时的形式约会C89。


-

Ian Collins。


>我读过那个以及正常的Java类函数定义,

Java与它无关。


>例如。 int main(int argc,char ** argv),你也可以选择使用
替代语法,即

int main(argc,argv)

int argc; char ** argv;
{
...
}
我一直在努力想到这种替代形式的情况比平常更具表现力,但我想我只是没有足够的想象力:)



它不是。此表单的主要用途是对于过时的编译器,

不接受ANSI C函数语法。我知道1983年的一个特定的b
我还有,但十多年来都没用过。


>人们什么时候更喜欢替代方式,为什么?



希望永远不要在现代硬件上使用新代码。他们可能更喜欢

如果唯一可用的编译器(至少是合理的预算)

接受此表单,并且不接受ANSI C表单。这将是b / b
主要用于被放弃。处理器。另一个原因是为了避免对遗留代码进行大规模更改,因为这可能是一个小小的变化。


2007年3月10日14:33:23 -0800,在comp.lang.c中,
Fr ************ @ googlemail.com 写道:


>我'已经读过正常和正常类似Java的函数定义,例如, int main(int argc,char ** argv),



Giggle。如果有的话,Java从C中偷走了这种风格。把它称为C-like ......


>你也可以选择使用
替代语法,即

int main(argc,argv)

int argc; char ** argv;



这是一种旧的,不推荐使用的预ISO风格,可追溯到20世纪80年代。

不要使用它。

-

Mark McIntyre


调试的速度是首先编写代码的两倍。

因此,如果您尽可能巧妙地编写代码,那么,根据定义,您可能不够聪明,无法对其进行调试。

--Brian Kernighan


I''ve read that as well as "normal" Java-like function definitions,
e.g. int main(int argc, char **argv), you can also choose to use an
alternative syntax, i.e.

int main(argc, argv)
int argc; char **argv;
{
....
}

I''ve been struggling to think of a situation where this alternative
form is more expressive than the usual one, but I guess I''m just not
imaginative enough :)

When do people prefer the alternative way, and why?

解决方案

Fr************@googlemail.com wrote:

I''ve read that as well as "normal" Java-like function definitions,
e.g. int main(int argc, char **argv), you can also choose to use an
alternative syntax, i.e.

There''s nothing Java like about them, they are standard C.

int main(argc, argv)
int argc; char **argv;
{
....
}

I''ve been struggling to think of a situation where this alternative
form is more expressive than the usual one, but I guess I''m just not
imaginative enough :)

When do people prefer the alternative way, and why?

Never, it''s an obsolete form that pre-dates C89.

--
Ian Collins.


>I''ve read that as well as "normal" Java-like function definitions,

Java has nothing to do with it.

>e.g. int main(int argc, char **argv), you can also choose to use an
alternative syntax, i.e.

int main(argc, argv)
int argc; char **argv;
{
...
}

I''ve been struggling to think of a situation where this alternative
form is more expressive than the usual one, but I guess I''m just not
imaginative enough :)

It''s not. The main use of this form is for obsolete compilers that
don''t accept the ANSI C function syntax. I know of one specific
one from 1983 that I''ve still got, but haven''t used in over a decade.

>When do people prefer the alternative way, and why?

Hopefully never for new code on modern hardware. They might prefer
it if the only compiler available (at least for reasonable budgets)
accepts this form, and does not accept the ANSI C form. This would
tend to be mostly for "abandoned" processors. Another reason would
be to avoid doing massive changes to legacy code for what is maybe
supposed to be a minor change.


On 10 Mar 2007 14:33:23 -0800, in comp.lang.c ,
Fr************@googlemail.com wrote:

>I''ve read that as well as "normal" Java-like function definitions,
e.g. int main(int argc, char **argv),

Giggle. If anything, Java stole this style from C. Call it C-like...

>you can also choose to use an
alternative syntax, i.e.

int main(argc, argv)
int argc; char **argv;

This is an older, deprecated, pre ISO style dating back to the 1980s.
Don''t use it.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan


这篇关于何时使用替代参数布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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