« first day (1014 days earlier)      last day (3933 days later) » 

user142019
8:00 AM
RAII is evil.
 
eeeeeeeeeeeeeeeeeeevil!
 
@jalf you do not have to have ternary operator to solve that though. If there was no ternary operator, and you really wanted to avoid default constructors,you can use a factory function that takes the bool. if true, return constructed with the first set of options, else with the second set of instructions. RVO will make it trivial. If you really wanted to, you could template it with perfect forwarding to pass either the first or second init list to the c'tor for 'T'
 
There is another process rewrite new data into the file, then I can read file in while loop, I get all the data everytime, In the view of that process, when to rewrite the file when I had read the old data from file?
 
@thecoshman this is not effing java
 
no factories !
 
8:05 AM
You are showing overblown solution to nonexisting problem
 
something like
template<typename T> T booleanInit(bool useFirst, std::init_list firstOptions, std::init_list, secondOptions){ if(useFirst){ return T(firstOptions);} return T(secondOptions);} auto booleanInit<Foo>(true, /* options */, /* options */)
 
@thecoshman Or I could write the simple solution which takes 10 seconds to write, and 5 seconds to read and verify as being correct (and which won't affect my compile times)
 
@thecoshman Come on man, that's just silly.
 
@BartekBanachewicz no, showing how ternary operator is not need. With pure C++ you can provide a function that does the equivalent that could have been part of std and not required extra syntax in the language.
 
@thecoshman None of us ever claimed it was needed
 
8:07 AM
@jalf do you feel the need to verify everything in in std or boost?
 
Functions aren't needed either
 
@thecoshman If I saw that code above to replace the ternary operator I'd be completely dumbfounded.
3
 
@chris nope, you can. Foo&& f = Foo(); f.x = 1;
 
@thecoshman I feel the need to verify the correctness of the code I write. Are you saying you don't?
@thecoshman Are you saying that the function you just wrote is in the standard lib?
 
¬_¬ must... resist... making... fully... working... replacement... for... ?:
 
8:08 AM
@Abyx Oh sorry, s/references/lvalue references.
 
@jalf no, but it should be :D well... and actually working version of it :P
 
@thecoshman What would it achieve? We know you don't need the operator. And we know you could do some ridiculous template hackery to "replace" it, but you cannot seriously be suggesting that this would be a good idea
that ? : becomes less harmful if it just has enough template <typename Blargh> littered all over it?
 
@thecoshman and you wouldn't improve a thing with that
 
@jalf if the additional syntax was never there, and you were really that concerned about default c'tor you would probably use it.
 
@thecoshman and again, how would this make the language better?
 
8:10 AM
@thecoshman If templates weren't there...
 
@jalf no ternary operator
 
You expressed a dislike for the ?: operator. And now you are saying "but the semantics of the operator are fine and should be implemented in the std lib, I just dislike that it has a nice, clean syntax! If it was more templatey, I wouldn't mind it"
 
@thecoshman why is that better?
 
@BartekBanachewicz well, we'd probably still be using void* a la C
 
8:12 AM
There is another process rewrite new data into the file, then I can read file in while loop, I get all the data everytime, In the view of that process, when to rewrite the file when I had read the old data from file?
 
@thecoshman it just shows you how dumb that reasoning is
 
@jalf no, I disagree that it is 'nice, clean syntax'
 
@thecoshman Compared to the monstrosity you described before?
 
Out of interested I wanted to see the assembly output of the ternary operator but GCC completely removed everything, even on -O1. Might as well use -O0.
 
@thecoshman and your solution does?
 
8:13 AM
@thecoshman but then you agree that you only actually have a probelm with the syntax of the operator, and not its semantics?
in which case, it is tempting to say "You expect nice syntax? In C++? Are you sure you're in the right language?" :p
 
#define TERNARY_START ?
 
In -O0 the ternary operator is a lot better than if(cond) { x = a; } else { x = b; }. Weird. I always thought they were equivalent.
 
C-like languages are full of horrific syntax. Function declarations look ridiculous, for example. Perhpas we should avoid using those too :)
 
@jalf no, I have a problem with the syntax and the semantics. Functionally it is fine, if you really are that worried default c'tors
 
@thecoshman How can you have a problem with the semantics if they are "functionally fine"?
 
8:15 AM
@thecoshman what's wrong with semantics?
 
And yes, I am worried about default ctors and assignment operators. I prefer to write my types so they are hard to misuse
 
@BartekBanachewicz because X = aBool ? A : B; is not the same as if(X=Bool){ A } else { B }
 
@thecoshman Why do you expect it to be the same?
void foo(int x is not the same as for (;;) either
 
@thecoshman and why it should be?
 
@jalf I thought they'd generate at least similar/same assembly but the ternary operator is superior.
 
8:17 AM
that's kind of the point in having different things look different
 
@Rapptz You could try something like: a() ? b() : c(); // functions a, b and c have been declared but are not defined
 
If you stopped mentally translating the operator into if-else blocks, maybe your problems would go away, because they are not equivalent :)
 
Xeo
26 mins ago, by thecoshman
@Xeo Just embed expressions into conditions
wat
 
@StackedCrooked I used uh..
int main() {
  int x = 10;
  int y;
  if(x > 9) {
    y = 100;
  }
  else {
    y = 20;
  }
  int w = x > 9 ? 100 : 20;
}
 
@Rapptz The compiler can calculate the result at compile time. You need to prevent this somehow.
Using extern int is also an option.
 
8:19 AM
Cin
 
Yeah I was just impressed that it did it even at -O1
 
 
Anyway, I like the ternary operator. Look at how many lines I saved!
when I find myself doing if(x) { } else { } with assignment I definitely try to use the ternary operator, I think it's silly to forbid it.
 
@BartekBanachewicz Bbbbbb
 
8:21 AM
Nsight for vs 2012 released
> Support for Direct State Access (DSA) feature of OpenGL
 
ternary is needed for constexpr functions
without ternary, it would not be possible to use selection.. (perhaps maybe using type selection)
 
@thecoshman How do you write gcd?
 
@StackedCrooked constexpr must go!
 
@StackedCrooked Not in C++1y.
 
nobody answer my question
so upset!
 
8:24 AM
select<number>::call() // select is specialized for different values of number
@jalf where to?
 
Xeo
@StackedCrooked Doesn't help.
 
@Xeo I haven't tried it. But I think it should work.
 
@StackedCrooked dunno. Follow the iterators? :p
 
Xeo
@StackedCrooked Not if number is a normal parameter.
 
Ah, right.
 
8:26 AM
but yeah... I never thought about the initialising use case...
 
What's wrong with constexpr? It makes things so much nicer to write compared to classes.
 
@thecoshman it's like the only use case for it?
 
If constexpr functions are executed at runtime then the code is slow due to the required functional coding style. (Or so I read.)
 
ternary operator has to return the same thing in both "sides", which makes it pretty limited.
 
8:28 AM
@TonyTheLion wow
I approve
 
@Rapptz I've seen it almost exclusively used in bad code it seems then. Things like myAlreadyExsitingVar = someBool ? foo : bar
 
@jalf :)
 
@thecoshman What's wrong with that?
 
Called Donkey Basketball, appropriately
 
@TonyTheLion I can almost understand that being thing... until you realise they are inside
 
8:29 AM
@thecoshman and?
 
you couldn't have picked an awful example like.. stack.back() == 4 ? stack.pop_back() : void()?
 
@thecoshman hahah true, quite baffling. Also that basketball court and those donkey hooves.
 
congrats
 
@Rapptz I just do not like the way it looks. if(someBool){ myExisting = foo; } else { myExsiting = bar; } IMO it's just clearer what is going on. and if you write it like that in the first place, you do not have to worry about wanting add more to the logic or expressions
@ScottW o_0
 
@thecoshman but you don't have to worry about that with ?: either. Because unlike if statements without the {} (which are evil), this syntax actually ensures that you can't add additional statements. So if you need to do that, you just rewrite it as an if/else :)
 
8:33 AM
@jalf There is the comma operator.
 
@chris fuck the comma operator
also anyone who invokes its name
 
expression SFINAE is cool
 
however, I will grant you that in that case, the operator unnecessary, and if you do dislike it, there's no reason not to use if/else instead in such cases :)
 
only use case for comma operator.
 
@jalf o_0 scope blocks are evil?
 
8:35 AM
@jalf, I just realized your penguin is in the shape of the HI hiragana.
 
According to Borgleader, expression SFINAE works in VS2013 which is cool.
 
@chris If you see someone use the comma operator inside the ?: operator, then you know that you are dealing with a twisted madman, and it would be best for humanity if you ensure that person steps away from the keyboard RIGHT NOW
@thecoshman No, not having the scope blocks is evil
 
Xeo
@Rapptz Oh, I gotta try that
@jalf {} even for single statements?
 
@jalf "without the {} (which are evil)" <-- huh?
 
@jalf That could be a thing in constexpr functions. I saw some article discussing the hacks for those.
 
Xeo
8:36 AM
> if statements without the {} (which are evil)
 
@thecoshman I never said (or never intended to say, at least) that the {} were evil. I said (or tried to say) that not having them is evil
And not "if statements without (the {} (which are evil))"
 
var ? (std::cout << "bad", void()) : (std::cin >> var, void())
 
@Xeo IMO yes
 
evil is evil.
 
@thecoshman he basically said ternary operator is safer that ifs
 
8:38 AM
Yeah I usually add { } for consistency and future proofing.
 
@jalf oh right right, yeah, totally agree. That's another pet peeve. @BartekBanachewicz is one of those freaky people who will not use braces for one line 'if blocks'
 
@ScottW at night? WTF?!
 
@BartekBanachewicz how is it that though?
 
Clutter vOv
 
@TonyTheLion I do that.
 
Ell
8:38 AM
I hate non braced ifs!
 
@BartekBanachewicz explicate
 
because at some point you change if (x) dostuff(); into if (x) printf("just some debugging aid"); dostuff(); and then fuck
 
@ScottW After lunch or something
 
@thecoshman You cant add additional stuff by mistake, thus you dont have to follow absurd rules like braces with every if
 
@thecoshman because you can't make this mistake with the ?: operator. the compiler will complain if you try to stick a semicolon inside it
 
8:39 AM
@jalf Add a brace right before dostuff() and press enter, then let it auto-format and add the ending brace.
 
@jalf well yeah... ternary is probably safer then braceless if blocks, but that's like saying, "sure, cure my arms off, rather that then be slowly dipped in acid instead of just sitting at home having a slice of cake"
 
@jalf then I add braces. Seriously, I forgot to add braces like once in my life when I was 10
 
@chris The point is when you come back to the code and add the printf, you forget to add the brace.
 
@jalf Yeah, I know the feeling.
 
@BartekBanachewicz I forget it regularly. And I regularly come across places in our code where others have forgotten it as well
 
8:40 AM
@thecoshman start using real arguments instead of your opinions and bollocks like that instead
 
@ScottW hahahahha <3
 
If you can remember it, that's great for your code, which no one else will ever need to touch. But if you're planning on others to see/read/contribute to the code, then just add the braces and save everyone the headaches
 
What? You said no and it still charged you? That's a... feature...
 
@jalf i usually don't complain about adding them
 
@BartekBanachewicz because you can never have an opinion on style ¬_¬
 
8:41 AM
@thecoshman you still haven't told us why it is like "curing your arms off". Why is the operator harmful?
 
@jalf yeah, I did mean 'cutting'
 
@thecoshman opinion on style != this code will never be allowed in my codebase
 
@thecoshman this part of the discussion was about safety, not style :)
@thecoshman ok, that makes more sense, but you still haven't explained how the operator is like cutting your arms off
 
@ScottW what flavor is it?
 
@jalf but I was getting at your point that ?: is 'safer' then 'brace-less if', which I will grant you it is, but 'brace-less if' is just bad in the first place IMO
 
8:43 AM
ohhhh
 
@thecoshman yes, but you're saying that it is still unsafe (just less unsafe than brace-less if), and I'm asking you why
what is unsafe about it?
 
@thecoshman you still havent stated why ?: is bad, except "because I think it is"
 
@jalf I'm not trying to say it is 'unsafe', just that I hate the look of it, and would avoid it at all reasonable costs (unreasonable being things like creating that crazy template idea... though I might try doing that just to test my template wankery)
 
@thecoshman you compared it to cutting your arm off. I think that qualifies as "saying it is unsafe"
 
@BartekBanachewicz I never said it IS bad, just that it LOOKS bad
 
8:46 AM
well, unless you're a surgeon, and are working in completely sterile conditions etc...
 
@thecoshman so the only reason is "because I hate the look of it"
 
and even then, I'm assuming there are sometimes complications :)
 
well... maybe I did say it is... I am sure some one will prove me wrong
@jalf hyperbol
 
@jalf It fails 0.1% of the time due to quantum stuff.
 
@thecoshman meaning we should disregard it? :p
 
8:47 AM
@thecoshman it's not enough to prevent me from using it in GLDR then
 
ternary operator
 
@ScottW quantum stuff and arm amputations
 
@jalf How did you go from ternary operator to that?
soon you'll start arguing about Hitler
 
@TonyTheLion it wasn't easy
@TonyTheLion nah, he never had an arm cut off, so he's completely irrelevant
 
@jalf I'm sure. I see no logical evolution.
@jalf hahahaha
 
8:48 AM
Fuck this
 
fever thingamahjiggy
 
I like arguing with @jalf when he is on my team :3
3
 
@ThePhD you are ill?
 
Ell
Brace less if is more difficult to read imho
 
8:49 AM
I don't think I am.
 
TBH, I used ternary operator for this little thing yesterday and I got it wrong the first few times.
 
It's just I feel like I have a fever, but when I get up and check, I don't have one.
So it's like, wat.
 
Oh
Go outside get some air
 
@Ell bullshit. Python doesnt have braces
 
@BartekBanachewicz but it has significant whitespace. C++ doesn't
 
8:52 AM
@jalf my whitespaces in c++ are significant for me
 
if you see an if in C++, followed by two indented lines, then it is pretty natural to assume that both lines are in the if-statement's body. But they're not
 
Who the fuck indents two lines
 
@BartekBanachewicz but you can't rely on it
@BartekBanachewicz someone who saw the if followed by one indented line, and added another line before it to help in debugging, or to add a log statement
 
Then he is the main problem in my code, not lack of braces
 
Ell
8:53 AM
@bartek I'm just saying for me it is harder to read, maybe not for everyone
 
@BartekBanachewicz I'd be a problem in your code then
 
@thecoshman Can't. ?: has magic that can only be replicated with macros that use ?: internally.
 
But no, if you write your code to make it easy to fuck up, then I'd say that is a problem in your code
 
If you don't use braces for your if statements then sooner or later you're gonna get burnt.
 
even if you never make that mistake, there's really no point in not just... eliminating it in the first place
if (x) y; -> if (x) {y;}, problem solved, with two more characters
 
8:55 AM
if(1);else;
 
And the bug might go unnoticed for a long time.
 
@StackedCrooked and when you get burned, it doesn't really matter much whose fault it was that you got burnt. You still got burnt
 
Poor Yuo.
 
Fuck him
 
Burn him.
 
8:56 AM
he had it coming
 
He should embrace his destiny.
 
Xeo
@jalf Depending on coding guidelines, it's also two extra lines
 
user142019
@jalf And the conclusion is that braceless if-bodies in C++ are the worst idea ever.
 
Ell
Rubys trailing if/unless is much better :3
 
@Xeo sure, but you can always amend your coding guidelines with a special case for this, if you really need to
 
8:59 AM
how about if(x>y)?true:false;
 
user142019
@Ell CoffeeScript and Perl have those too. I like them for short stuff.
 

« first day (1014 days earlier)      last day (3933 days later) »