问题描述
当然可以通过适当使用现有的
运算符来获得效果,但^^运算符会产生良好的对称性(以及
对我有用)在我正在努力的事情上)。我是唯一一个
会发现它有用的人吗?
-
Christopher Benson-Manica |我*应该*知道我在说什么 - 如果我
ataru(at)cyberspace.org |不,我需要知道。火焰欢迎。
Of course one can get the effect with appropriate use of existing
operators, but a ^^ operator would make for nice symmetry (as well as
useful to me in something I''m working on). Am I the only one who
would find it useful?
--
Christopher Benson-Manica | I *should* know what I''m talking about - if I
ataru(at)cyberspace.org | don''t, I need to know. Flames welcome.
推荐答案
你的意思是如果一个操作符只有一个操作数就返回1
非零,否则为0?是的,那会很有用。但是忘了
的短路语义。想想看,你会明白为什么。
-
/ - Joona Palaste(pa*****@cc.helsinki。 fi)-------------芬兰-------- \
\-- ----------------- ----规则! -------- /
You mean an operator that returns 1 if exactly one of its operands is
nonzero, and 0 otherwise? Yes, that would be useful. But forget about
the short-circuit semantics. Think about it and you''ll see why.
--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
你的意思是如果一个操作符只有一个操作数是非零的,则返回1,否则为0?是的,那会很有用。但忘记了短路语义。想一想,你会明白为什么。
You mean an operator that returns 1 if exactly one of its operands is
nonzero, and 0 otherwise? Yes, that would be useful. But forget about
the short-circuit semantics. Think about it and you''ll see why.
如果有一元一元的操作员,我们可以写日文表情
到我们的代码。例如:
sashimi ^ = ^ kawaii;
-
/ - Joona Palaste(pa **** *@cc.helsinki.fi)-------------芬兰-------- \
\-- ----------- ----------规则! -------- /
战争!咦!天哪,你们呀!到底有什么好处呢?我们询问了Quimby市长。
- Kent Brockman
Also if there were an unary ^ operator, we could write Japanese smileys
into our code. For example:
sashimi ^=^ kawaii;
--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"War! Huh! Good God, y''all! What is it good for? We asked Mayor Quimby."
- Kent Brockman
如果你写的条件是合乎逻辑的(那就是避免if(x)
style idioms),那么使用现有的xor运算符就可以实现与你提出的^^相同的东西,不是吗?我的意思是,对于xor运算符,可能没有
短路评估。
-nrk。
-
删除电子邮件的devnull
If you write your conditions to be all logical (that is avoid the if ( x )
style idioms), then using the existing xor operator would achieve exactly
the same thing as your proposed ^^, wouldn''t it? I mean, there can be no
short-circuit evaluation of an xor operator.
-nrk.
--
Remove devnull for email
这篇关于为什么没有逻辑XOR运算符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!