如果...会更容易阅读 [英] would C be easier to read if...

查看:40
本文介绍了如果...会更容易阅读的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一些语法并没有太多超载...


如果指针取消引用和指向类型的指针只是在思考

单独的语法(即对其中一个使用''*'之外的字符)它会使得b / b $ b更容易阅读。你不会得到这样的东西:


pthread_create(& thread,NULL,(void *(*)(void *))ThreadProc,(void

*)参数);

some of the syntax wasn''t overloaded so much...

Was just musing that if pointer de-referencing and pointer-to-type had
seperate syntax (ie use a character other than ''*'' for one of them) it would
make things much easier to read. You wouldn''t get stuff like:

pthread_create(&thread, NULL, (void *(*)(void*))ThreadProc, (void
*)parameter);

推荐答案

Robert Smith写道:
Robert Smith wrote:

一些语法并没有太多超载...


如果指针取消引用和指向类型指针那么只是在思考

单独的语法(即对其中一个使用''*'以外的字符)它会使得b / b $ b更容易阅读。你不会得到这样的东西:


pthread_create(& thread,NULL,(void *(*)(void *))ThreadProc,(void

*)参数);
some of the syntax wasn''t overloaded so much...

Was just musing that if pointer de-referencing and pointer-to-type had
seperate syntax (ie use a character other than ''*'' for one of them) it would
make things much easier to read. You wouldn''t get stuff like:

pthread_create(&thread, NULL, (void *(*)(void*))ThreadProc, (void
*)parameter);



肯定要么'ThreadProc`已经是正确的类型,在这种情况下

演员可以而且应该被丢弃,或者它不是'不,在这种情况下

演员阵容是一个等待显示的bug,而'ThreadProc`应该是

固定。


是吗?


-

我徒劳无功。它不会这样做。 /傲慢与偏见/


Hewlett-Packard Limited Cain Road,Bracknell,注册号:

注册办事处:Berks RG12 1HN 690597 England

Surely either `ThreadProc` is already the right type, in which case
the cast can and should be discarded, or it isn''t, in which case
the cast is a bug waiting to manifest and `ThreadProc` should be
fixed.

Yes?

--
"In vain I have struggled. It will not do." /Pride and Prejudice/

Hewlett-Packard Limited Cain Road, Bracknell, registered no:
registered office: Berks RG12 1HN 690597 England


Chris Dollin写道:
Chris Dollin writes:

> Robert Smith写道:
>Robert Smith wrote:

> pthread_create(& thread,NULL,(void *(*)(void *))ThreadProc,(void
*)参数);
>pthread_create(&thread, NULL, (void *(*)(void*))ThreadProc, (void
*)parameter);



肯定要么'ThreadProc`已经是正确的类型,在这种情况下

演员可以而且应该被丢弃,或者它不是'不,在这种情况下

演员阵容是一个等待显示的bug,而'ThreadProc`应该是

固定。


是?


Surely either `ThreadProc` is already the right type, in which case
the cast can and should be discarded, or it isn''t, in which case
the cast is a bug waiting to manifest and `ThreadProc` should be
fixed.

Yes?



希望''参数''是一个非常量指针,所以void * cast

也可以删除。


你需要用不可读的

类型转换来填充代码的时间,键入dede违规类型可能是有意义的。


-

Hallvard

And hopefully ''parameter'' is a non-const pointer so the void* cast
can be dropped too.

The times where you do need to clutter the code with unreadable
type casts, it may make sense to typedef the offending type.

--
Hallvard


" Robert Smith" < so ***** @ somewhere.comwrites:
"Robert Smith" <so*****@somewhere.comwrites:

一些语法没有超载这么多......

只是沉思,如果指针取消引用和指向类型的指针具有单独的语法(即对其中一个使用*之外的字符),它会

使事情更容易阅读。你不会得到这样的东西:


pthread_create(& thread,NULL,(void *(*)(void *))ThreadProc,(void

*)参数);
some of the syntax wasn''t overloaded so much...

Was just musing that if pointer de-referencing and pointer-to-type had
seperate syntax (ie use a character other than ''*'' for one of them) it would
make things much easier to read. You wouldn''t get stuff like:

pthread_create(&thread, NULL, (void *(*)(void*))ThreadProc, (void
*)parameter);



所有* s都有相同的含义,不是吗?如何更改符号帮助


-

Ben。

All the *s there have the same meaning, don''t they? How would
changing the symbol help?

--
Ben.

这篇关于如果...会更容易阅读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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