。作为m_的替代 [英] . as an alternative to m_

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

问题描述

我知道这不是建议的地方,但我只需要发泄。为什么

不要让我们使用c ++编译器。作为说this->的方式,因此一个

替代m_


struct foo {

int a;

void bar(int a){

.a = a;

}

};

I know this isn''t the place for suggestions, but I just need to vent. Why
dont c++ compilers let us use . as way of saying "this->", and hence an
alternative for m_

struct foo {
int a;
void bar(int a){
.a = a;
}
};

推荐答案

Chris Becke写道:
Chris Becke wrote:

我知道这不是地方建议,但我只需要发泄。为什么

不要让我们使用c ++编译器。作为说this->的方式,因此一个

替代m_


struct foo {

int a;

void bar(int a){

.a = a;

}

};
I know this isn''t the place for suggestions, but I just need to vent. Why
dont c++ compilers let us use . as way of saying "this->", and hence an
alternative for m_

struct foo {
int a;
void bar(int a){
.a = a;
}
};



恕我直言,''this->''(或者,如果你将self指定为(* this this),''self。 '')

实际上比点更易读。我实际上更愿意看到

这个 - 或者m_而不是点。此外,''a''是一个

变量的愚蠢名称;对不起,如果这会冒犯你。


原因是它没有足够的购买(或任何东西,真的)而且

使语法变得复杂,大多数可能。


V

-

请在通过电子邮件回复时删除资金''A' />
我没有回复最热门的回复,请不要问

IMHO, ''this->'' (or, if you define "self" as "(*this)", ''self.'') is
actually more readable than the dot. I would actually prefer to see
this-or m_ than the dot. Besides, ''a'' is such a dumb name for a
variable; sorry if that offends you.

The reason is that it doesn''t buy enough (or anything, really) and it
complicates the grammar, most likely.

V
--
Please remove capital ''A''s when replying by e-mail
I do not respond to top-posted replies, please don''t ask


它更复杂但没有明确的 - 所以不是那样的更多

更复杂的方法。


并且,a被选为愚蠢的:P它只是用于说明目的的样本

毕竟。


我想。像这样有一个整齐的对称性。


你可以写一个外部函数


void bar(foo& s,int a){

sa = a;

}


或会员功能(如前所述)。


void foo:bar(int a){

.a = a;

}


我不喜欢我知道。写得像是一个相当合理的延伸。


Victor Bazarov < v。******** @ comAcast.netwrote in message

news:g7 ********** @ news.datemas.de ...
its more complicated htan nothing but it is unambiguous - so not that much
more complicated methinks.

And, a was chosen to be dumb :P Its just a sample for illustration purposes
afterall.

I think . like this has a neat symmetry.

You could write an external function

void bar(foo & s, int a){
s.a = a;
}

or a member function (as before).

void foo:bar(int a){
.a = a;
}

I don''t know. Written like that its a rather logical extension.

"Victor Bazarov" <v.********@comAcast.netwrote in message
news:g7**********@news.datemas.de...

Chris Becke写道:
Chris Becke wrote:

>我知道这不是建议的地方,但我只需要发泄。为什么不使用c ++编译器。作为说this->的方式,因此是一个替代m_

struct foo {
int a;
void bar(int a ){
.a = a;
}
};
>I know this isn''t the place for suggestions, but I just need to vent. Why
dont c++ compilers let us use . as way of saying "this->", and hence an
alternative for m_

struct foo {
int a;
void bar(int a){
.a = a;
}
};



恕我直言,''这 - >''(或者,如果你将self指定为(* this),''self。 '')

实际上比点更易读。我实际上更愿意看到

这个 - 或者m_而不是点。此外,''a''是一个

变量的愚蠢名称;对不起,如果这会冒犯你。


原因是它没有足够的购买(或任何东西,真的)而且

使语法变得复杂,大多数可能。


V

-

请在通过电子邮件回复时删除资金''A' />
我没有回复最热门的回复,请不要问


IMHO, ''this->'' (or, if you define "self" as "(*this)", ''self.'') is
actually more readable than the dot. I would actually prefer to see
this-or m_ than the dot. Besides, ''a'' is such a dumb name for a
variable; sorry if that offends you.

The reason is that it doesn''t buy enough (or anything, really) and it
complicates the grammar, most likely.

V
--
Please remove capital ''A''s when replying by e-mail
I do not respond to top-posted replies, please don''t ask



2008-08- 05 16:25,Chris Becke写道:
On 2008-08-05 16:25, Chris Becke wrote:

我知道这不是建议的地方,但我只需要发泄。为什么

不要让我们使用c ++编译器。作为说this->的方式,因此一个

替代m_


struct foo {

int a;

void bar(int a){

.a = a;

}

};
I know this isn''t the place for suggestions, but I just need to vent. Why
dont c++ compilers let us use . as way of saying "this->", and hence an
alternative for m_

struct foo {
int a;
void bar(int a){
.a = a;
}
};



因为它不那么冗长,因此不太好。如果节省时间由

输入。而不是this->很重要,这意味着你在开始编码之前没有足够的思考。


此外,使用神秘的字符来表示不同的东西导致

珍珠语法,很容易与诅咒混淆。


-

Erik Wikstr ?? m


Because it is less verbose and thus less good. If the time saved by
typing "." instead of "this->" is significant it means you are not
thinking enough before you start coding.

Besides, using cryptic characters to mean different things leads to
pearl syntax, which can easily be confused with cussing.

--
Erik Wikstr??m


这篇关于。作为m_的替代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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