« first day (1055 days earlier)      last day (3894 days later) » 

12:09 AM
> void Main()
I'm pretty sure this could mislead a lot of beginners. "The guy from Microsoft did it, so I should too!"
 
C++ 4.8.1. Seems legit.
@MohammadAliBaydoun I need to watch all of these later.
 
@chris I missed the first presentation and most of "Don't Help the Compiler", so I'm most likely going to restart later ;p
I think someone in the audience just asked him if they could consider rewriting the whole thing in C for reliability :|
Or I misheard something
 
TIL wikipedia has articles on the dogs of US Presidents.
 
Hm, I wonder if I could find a INTERCAL parsing library...
 
12:30 AM
@MohammadAliBaydoun Why? It's perfectly fine to have a Main method with whatever return type and arguments you want. It has nothing to do with main.
@MohammadAliBaydoun rewrite the Windows kernel in C++
 
@FredOverflow I assumed it was a typo, because I noticed quite a few typos in there :P
Like this one loop where he uses j as an index but increments i
 
@MohammadAliBaydoun In my next programming language, j is going to be a keyword, so you cannot confuse i with j ;)
 
@FredOverflow Short for jelly or just
 
What was Java reserving goto for again? I forgot if they had an idea, or just for safety.
 
Also lower-case l is a keyword, so you cannot confuse it with the number 1.
@Pawnguy7 They reserved the goto keyword in case they would have to introduce the goto statement later.
 
12:36 AM
I use Monaco in my favorite text editor for that purpose
 
@FredOverflow yes. Did they have an idea of what it would do in mind? (say, C++ goto).
 
@Pawnguy7 Hopefully it's supposed to punch the programmer in the face and throw a compile error.
 
C++20: We've reserved all identifiers in case we want to make new keywords in the future. You must now only use underscores in identifier names.
 
Haha. I guess you wouldn't really need it with the break labels (say, for three deep loops and stuff).
 
int _ = 3;
int __ = 5;
for (int ___ = 0; ___ < 10; ___++) {
    std::cout << _ + __ << '\n';
}
 
12:40 AM
I would argue that the slight annoyance of getting out of 3 for loops without goto is worth not seeing any goto statements in other places.
 
@LaylConway You break out of nested loops inside Java without gotos.
outer:
for (...
    for (...
        for (...
            if (...) break outer;
 
In C++, for breaking out of loops, I use a try {} catch and throw.
 
don't
 
oh hey neat, I didn't know that one
 
That is what I meant by break labels.
 
12:42 AM
@MohammadAliBaydoun You evil evil person
 
@FredOverflow I recently learned this is bad, but no reasons were given :<
Is it because it seems like a hack or something? :o
 
@MohammadAliBaydoun You might as well use setjmp.h if you're going to do that
 
Exceptions are for exceptional situations, not for normal control flow.
Put the for loops inside their own function and just use a return statement.
 
I think breaking out of such loops is valid. For example, I always hear it here - and this is a good thing - to make it readable. To me, a goto that obviously gets you out of the loop is better than a bunch of state variables that hinder the reading of what you actually want.
 
12:43 AM
You would want to put three nested for loops into their own function for readability, anyway.
 
@FredOverflow Oh look - an outbreak of sanity:)
 
That could work.
 
@MohammadAliBaydoun biggest problem with using throw for flow control, next to that maintainers will hate you, would probably be that throw is slow >:C
 
@LaylConway It's a one-man personal project, I can't hate myself ;.;
Or well, I can
But eh, I guess dividing this into functions would be better
 
didn't know that Java feature for breaking out of nested loops though, great that it kinda entirely removes goto out of the picture in favor of something similar but different ;)
 
12:46 AM
@MohammadAliBaydoun It would be easier if C++ supported nested functions, but I just dream..
 
Functions kinda feel like an iffy solution for that
guess it works cleaner then boolean juggling though
 
Functions are actually the solution in my context
I'm trimming an image
 
What else do people use goto for?
 
hopefully nothing
 
@Pawnguy7 Italians use it for Spaghetti
 
12:48 AM
I think in my current project there's only one spot where I need to break out of a nested for
can't remember where though
 
There are 4 in mine but only because I have 4 functions that trim :P (trim_left, trim_right, trim_top, trim_bottom)
@MartinJames Wait a second, I just realized you could use lambdas for that :O
 
I don't think I have used it besides breaking out of such loop constructs.
 
@MartinJames Still seems unnatural though
 
it does seem unnatural, but languages sometimes lack
aaaand thank you code analysis for spotting a stupid mistake
 
I never tried Code Analysis before. I guess I can give it a shot
 
12:57 AM
yay me, it appears I successfully am sending and receiving packets now
Gosh, 3AM already, perhaps I should sleep
 
I woke up at 9PM and it's 4 AM now, I wish I could sleep and restore my sleeping cycle :<
If I go to bed, I'll be sitting there the whole time
 
1:23 AM
I have a program that parses a vector of actions (vector<actions>). Special things need to happen during transitions from different kinds of vectors. What is way to handle this scenario what is this pattern called?I am thinking of keeping track of the last item and then determing the transition by having special cases for different class to current transitions, but this state of affairs doesn't seem very C++.
 
Is it possible to make any sort of generalizations for the actions?
Because then you could have a function that takes 2 sets of these values and computes data for a transition
 
@MohammadAliBaydoun In my case I am controlling a bunch of equipment and I write a script for each event. Certain events such as going from acquisition to auto-focus requires changing the camera while going from certain mechanical motion to auto-focus doesn't require these kind of changes.
@MohammadAliBaydoun I am probably going to have a big function that takes the new and old state and route the transition, but it still doesn't feel very OOP
 
You can have a general state that you start at
when changing phase,
you undo what has been done by the current state
when you undo, you're back to the generic state
so when going to another state, you don't need to know anything about the previous state
Does it sound good? :p
The doing would be in a constructor and the undoing in a destructor
 
1:38 AM
After skimming over that, it has something to do with states? :D
 
@Pawnguy7 Trying to figure out the object oriented way to manage a system where states state transitions should trigger events. program is a ticker tape that executes states, certain transitions require different events.
 
I cannot think of anything besides what you stated, sorry.
 
1:56 AM
What is the point of the copy constructor again? I feel I have forgotten something obvious, but it escapes me.
 
user425495
T a(b); // b is of type T
 
@Mikhail Do you want to pass data between states in other words?
 
@Mikhail elaborate
 
@justinls Yes. I just forget why it is different than a constructor which happens to take an instance of itself. I seem to be mixing them up.
 
@Pawnguy7 with the regular constructor, you're constructing an object from scratch
@Pawnguy7 with the copy constructor, you're doing the same, except you use the data of another object
 
user425495
2:00 AM
a constructor which takes an instance of itself is a copy constructor provided it's passed by reference
 
@MohammadAliBaydoun yo wc3 was awesome nbd
also JassScript ;D
 
Hm. Ok then. Not sure why I am getting mixed up now.
 
@EiyrioüvonKauyf I barely play it anymore nowadays :<
 
i stopped for years now
all bots
i feel like i friended you on it years back though haha
i remember magtherion from somewhere
whatevs
 
Magtheridon is in the campaign
 
2:05 AM
idk
 
@EiyrioüvonKauyf Its a code to control a bunch of devices I wired up. The program executes a script that contains events such as takeImage moveArmduring certain transitions actions need to occur: for example during a takeImage to moveArm transition the shutter must close but not during a takeImage to moveStage (because the shutter closing takes a few seconds this is a step to avoid...
 
... and you can't just have a state variable?
that would be the simplest way
 
@EiyrioüvonKauyf certainly, but I am trying to figure out how to mange the complexity of the transitions. Specifically, I am thinking of writing a function that operates on 2 variables (old_state and new_state) but this feels like putting code in the wrong place.
 
just have a state migration function that does cleanup and movement
 
Anyone already watched GoingNative?
C9 hasn't yet released the recordings. :(
 
2:20 AM
@MarkGarcia i missed part of bjarne's keynote and i didn't watch the last talk (Compiler++) watch the rest though
 
@MarkGarcia I did
 
I have no idea what it is, and don't care enough to look it up. I seem to have seen it brought up here several times today, though.
 
@MohammadAliBaydoun Where? Could you please give a link?
 
Well, I only watched half the second part and Compiler++
 
@Borgleader In Channel9?
 
2:21 AM
@MarkGarcia the link is on the starboard
 
I mean, that is where you watched them?
 
@MarkGarcia I watched it streamed
 
Oh.
Then I'm late for the party. :(
So sehe is at the conference?
 
Sehe was there? ;_;
 
no i think he recorded a lofi version of it (from the stream)
 
2:22 AM
Oh.
 
Hm
I forgot what the max columns is on Github before it scrolls
 
But did Channel9 livestream the talk(s)?
 
microsoft did yes
that's the stream i was watching
 
So I'm here waiting for the downloadable videos.
Anyway, are there anything interesting? (But not much details as to spoil me :) )
 
Sean Parent's (C++ Seasoning) I thought was pretty interesting, STL's talk too (about not babysitting your compiler)
 
2:25 AM
Cool. I'm pretty much excited.
 
Babysitting the compiler?
 
@Pawnguy7 that's not the official title but that was the idea of the talk
 
125 for those wondering
 
@Borgleader I didn't understand the idea of what that means.
 
@Rapptz Code preview?
 
2:28 AM
@Pawnguy7 Don't try to optimize things for your compiler, you're often getting in it's way
in other words, don't treat it like a baby (babysit) it's often smarter than you
 
Is this in terms of premature optimization, or after you notice something that, as is, needs to be optimized?
 
watch the talk :P
 
Might go over my head :D
Is this indentation odd?
(second line)
 
the gap after the if looks weird as hell to me
 
@Pawnguy7 I don't usually put spaces after ifs, but I don't find that odd.
 
2:38 AM
I don't usually either, but the misallignment bugged me slightly.
Seeing as how it is basically a switch.
 
I wish "Closed as undefined behavior." reason could be a valid one.
 
dupe as (similar UB question) is close enough for me
 
Once VTC to go...
 
@Pawnguy7 wtf is that. of course it's weird; code should be easy to read
 
2:43 AM
I usually don't do stuff like this, but it seems to be more common in others. Though that seems to be more for function parameters.
 
I appreciate the OP closing his own question.
I was not aware of sequence points. Thanks for pointing to right direction. Marked as dupilicate. — Rohit Kandhal 1 min ago
Duplicate "i". :P
 
Did you see that guy who just posted his entire homework description + code and basically asked "did i do this right?" =.=;
 
I upvoted him for closing his own question
 
he doesnt have enough rep to close his own question...
 
@MohammadAliBaydoun It's actually a nicely formulated question, but still a duplicate.
 
2:46 AM
awww
time to watch the last ever Futurama.
@Pawnguy7 ewwwwww
 
@Borgleader You can actually close your own. Though I was surprised at first.
 
I just tried on one of my own.
@Borgleader WTF is that?
 
That question was on SO a few minutes ago, and it was more or less "plz review my code"
 
Wall of text!
 
2:48 AM
i told him code reviews were for CodeReview.SE
 
I doubt it would be answered nicely, or even answered at all.
 
I think a simple "Yeah" is a valid answer.
If you're right, okay. If you're wrong, he submits the assignment, gets it wrong and learns to never post walls of text like that ever again.
Or not.
 
I would never post assignment code (at least not the full code) on the internet like this.
 
Taking a primitive by reference? Not sure I have seen that before.
 
primitive by ref as in double& someDouble ?
 
2:59 AM
Yes.
I have seen some, for lack of a better word, "fill-in" things, but never a primitive.
 
That is pretty much one of the only obvious use cases
 
@Pawnguy7 Why not? Any type can be referenced.
 
Dang, Cookie Clicker is like even more addicting now that it has achievements and everything.
@DeadMG Except a reference.
 
3:18 AM
@chris A pointer is still considered a reference. ;)
 
@chris Reference collapsing.
 
@DeadMG I kind of meant it more logically adding a reference to anything than literally doing T &.
 
@chris Adding a reference to it is doing T&.
 
Poorly formulated but I find it very interesting: stackoverflow.com/questions/18627191/…
 
say I've forked someone's repo, made some changes, made a pull request, and it got merged... is there something on github I can do to get commits made by the repo owner after the merge? Or do I do that locally (pull from the master repo, then push that to my fork on github?), or do I just delete and refork...?
 
3:25 AM
@DeadMG Well sure, but it's still not truly referencing the initial type (the reference itself) when they are collapsed. Anyway, it's too small to go on about. It's just a difference in ways of thinking about it.
 
@chris The difference would be non-observable. Plus, remember that per Standard, references do not really exist.
 
@DeadMG Yeah, which is why you can't reference them I guess :p
 
@Pawnguy7 A little, but not terrible. I think I'd use something like: ideone.com/jtlV08
 
The default inheritance mode is private right? I mean, when you inherit without indicating something after the colon and before the base type.
So access specifiers applies to all names, and not just for methods and variables. TIL.
 
@MarkGarcia Same accessibility as for members, so public for a struct, private for a class.
 
3:35 AM
Oh.
 
@LucDanton heyo.
 
You convinced me to make concepts!
decently entertaining
 
What did you start with?
 
What do you mean?
 
3:40 AM
What concepts implemented you first? :)
 
Outside of the ones provided in the standard I did the LessThanComparable/Comparable/EqualityComparable, NullablePointer, Swappable, and the Iterator ones
 
Hehe, in soviet russia, concepts implement you
 
heh
 
In Soviet Russia, YOU rape Metaprogramming
 
In Soviet Russia, undefined behavior works!
3
 
4:01 AM
@Igor, I updated the post, please review. — xmllmx 17 secs ago
His edit is so differently aimed.
 
@Mark, the question has been updated. Please review the post. — xmllmx 31 secs ago
Wow.
That's quite rude of him :|
 
Yeah, wildly different.
Yay, my first billion cookies (again).
 
@MohammadAliBaydoun I think there's a topic about that in Meta Stack Overflow.
Hmm...
 
I'm going to answer him by saying that a function pointer cannot represent a capturing lambda
because they are fundamentally different
Data pointers and function pointers don't mix, is that correct?
I read an answer made by Jerry once explaining how the reasons are historical or something
 
@MohammadAliBaydoun Hmmm... That made me interested in checking the value of function pointers. Lemme try.
 
4:14 AM
@MarkGarcia I think it was about how some old systems would use 16-bits to represent function pointers, but I may be wrong
It's in the FAQ :D
Or, the About
A lambda that doesn't capture can be represented with a function pointer because it doesn't need to store any state, so it is legal in such a case, right?
 
@MohammadAliBaydoun Yes.
 
Reason I'm asking is because I don't use function pointers like a Cfag
 
Me too.
Interesting.
All have the same value.
 
Try giving them side effects
 
Oh right. Or turn off optimization.
 
4:21 AM
That works too /o/
 
22
A: How to print function pointers with cout?

anonThere actually is an overload of the << operator that looks something like: ostream & operator <<( ostream &, const void * ); which does what you expect - outputs in hex. There can be no such standard library overload for function pointers, because are are an infinite number of types of them. ...

Damn.
They are actually printed as bools.
 
@MohammadAliBaydoun Not entirely historical -- some current DSPs (for one example) have entirely separate address spaces for data and code (i.e., physically separate memory buses).
But yes, on MS-DOS you had medium model (near pointers to data, far pointers to data) and compact model (far pointer to data, near pointer to code) where pointers to data and pointers to code were different sizes.
 
And TIL that function pointers cannot be casted to void*. They're invulnerable!
 
4:48 AM
There are still probably some workarounds
hacky ones
where you create a pointer with an address that just happens to be the address of a function pointer :P
 
The user reviews on that cable are hilarious — rmx May 5 '11 at 10:52
Follow the comment link and you'll see.
 
 
1 hour later…
6:08 AM
user image
6
 
If I have vector vector<std::pair<string, int> > vec can I send vec it through socket and getting its values at receiver?
 
@Karimkhan You'll have to "flatten" it, typically with some serialization library or other first.
 
@JerryCoffin Can you please elaborate?
 
@Karimkhan You'll need to walk through the items in the vector and write out the individual items so code on the other end can read it back in and create a copy of the original data structure. This process is called "serialization". There are libraries (e.g., Boost Serialization to automate parts of this to some degree.
 
Ell
@karimkhan google protocol buffers + boost asio
 
6:26 AM
Who is starring all these messages
 
Aaaack!
 
@JerryCoffin Ok, if i use link list. And insert string n int value in each node. Then I send reference of linked list then can I fetch it at recv side?
 
Yes, Aaaack!
@Karimkhan Don't do that, it's over-engineering and a bad method
It's bad because there is no good reason to use a linked list (unless you have one :P)
 
@Karimkhan You need to send the data in the linked list across the wire, and re-constitute it on the receiving side.
 
6:30 AM
@Telkitty猫咪咪 Starararararararrrrrrrrrrrrrrrrrrzzzzzzzzzzzzzzz!!!
 
@MohammadAliBaydoun But what is other way. I find Boost serialialization complex
 
@Karimkhan It's less complex than some of the other parts of Boost, I can tell you that
It's also worth learning to use, because Boost is a very high quality collection of libraries
 
@MohammadAliBaydoun So for that do I need to make bunch of functions or what is there?
 
@Karimkhan For your classes, you can have serialize functions that do the same thing as the examples in the Boost docs do pretty much
 
@MohammadAliBaydoun Ok, thanks. My actual purpose is this, if you can suggest me anthing else stackoverflow.com/questions/18598481/…
 
6:36 AM
stringstream is simple enough to work.
Write data to the stringstream when you want to send, and read it in the same order when you receive
To convert a stringstream into a char*, use it's str() method to get a string, and then use std::string's c_str() method.
 
so for each values I need to make send() call,
 
user1804599
@Pawnguy7 need more braces.
 
user1804599
Also, need more switch, but C++ sucks.
 
@Karimkhan The principle is that you want to take all your data from the structure, write it to a flat char* in a consistent and convenient way, and send the whole buffer
stringstream makes this easy
 
Ell
Protobuf is so easy :3
 
6:43 AM
@not-rightfold I already showed how to do it quite nicely without a switch.
 
@MohammadAliBaydoun Actually for each word I have int count value mapped with it. Which I want to store in database at recv side! In Stringstream I can work with char data only, then dealing with int value would left fo me!
 
stringstream does formatted I/O, you don't need to handle that shit
 
@Ell asio protobuf will do without making edit to my exisiting system for my above case?
 
Let's say you have an empty stringstream stream:
    int n = 9;
    char c = 'c';
    std::string s = "what";

    // write to stream
    stream << n << c << s;

    // read from stream
    stream >> n >> c >> s;
 
@MohammadAliBaydoun This seems good. after this stream << n << c << s; directly I can send it via send()?
I am talking about sending the stream!
 
6:49 AM
stream.str().c_str()
When you receive, build a string and a stream out of the string and start reading
By the way, I have 0 experience with using sockets and networking :P
 
ohh
 
Ell
Boost asio is for networking
Google protobuf is for serialising messages
 
@MohammadAliBaydoun You can't do that.
That's UB son.
 
Where is UB invoked?
 
stream.str() returns a temporary, calling .c_str() on it won't work like you expect it to.
 
7:00 AM
Oh, that part. Should be easy to fix :p
 
49
Q: C++ stringstream, string, and char* conversion confusion

Graphics NoobMy question can be boiled down to, where does the string returned from stringstream.str().c_str() live in memory, and why can't it be assigned to a const char*? This code example will explain it better than I can #include <string> #include <sstream> #include <iostream> using namespace std; in...

 
std::string str = stream.str();
const char* buffer = str.c_str();
:|
 
Xeo
> The Way of the Exploding Tuple
I'll be sad if he doesn't use the indices trick.
 
7:18 AM
I'll be sad if I miss half of the conference again :(
 
Xeo
It starts in roughly 8 1/2h
 
@Xeo who?
 
@Xeo I didn't see it. But is this his first talk?
 
Xeo
Nah, on day 3
 
7:23 AM
Ah. Then he'll inevitably use it. He's the one for tricks :/
 
user1804599
Today is a wonderful day!
 
@R.MartinhoFernandes oh. eheh. I just re-uploaded it (takes only 7'20") because I forgot about my nightly backup kicking in (and removing all things not on my 'master')
 
@sbi sounds good then :D
 
@sehe: What kind of stream is the stared GN2013 link?
VLC does not like it.
 
mawning
 
user1804599
7:28 AM
> So have you heard of the next C++ Standard? No, it is not C++11.
 
user1804599
lel
 
ergh... is there anywhere to watch the stream from yesturday?
 
@wilx Stream's probably down
 
Xeo
@thecoshman don't think so
 
@Xeo (╯°□°)╯︵ ┻━┻ fuck
why can't they just use twtich like any sane person
 
7:31 AM
@wilx it does, but it's not live now
 
Oh.
 
@not-rightfold extremely loudly?
 
Xeo
Alright, time for work
 
user1804599
@sehe YES :D
 
@wilx If you can put up with crappy quality: GN2013_KeyNote_LQ.mp4 (at 61%, ~5min40s) and GN2013_parent-sean.mp4 (at 100%)
2
 
user1804599
7:34 AM
I need a for each loop. :(
 
@user2346536 Come on, don't be ridiculous. If that's your question, just drop the original question completely and write your question properly in the ... question box! This is illegible in the comment and I will not try to read it. — sehe 3 secs ago
@not-rightfold I often do. What's the occasion (inb4: two independent iterators walking not in lockstep?)
I think what Sean/James mean is: it's ok to write loops but only do it when you implement your own abstracted algorithm (about ASL Sean said: "(we) have many versions of simple algorithms, don't hold back"
 
user1804599
7:50 AM
@sehe I need to do something slightly differently if I'm dealing with the first iteration. :<
 
@not-rightfold That's a code smell, IMO. Sounds like std::accumulate or std::adjacent_find
 
user1804599
@sehe no no no
 
user1804599
I'm generating HTML.
 
sooo. You need an HTML builder that knows. And use an output iterator to append
 
user1804599
I'm using a template engine.
 
user1804599
7:54 AM
<? $had_first = FALSE; ?>
<? foreach ($xs as $x): ?>
<!-- stuff -->
<? $had_first = TRUE; ?>
<? endforeach; ?>
 
user1804599
:D
 
in OpenGL Done Right, 1 min ago, by sehe
@thecoshman Calm down big boy :) I see you'r having fun
@not-rightfold That a euphemism for php now ?
 
user1804599
@sehe :x
 
@not-rightfold So, indeed you need accumulate but the engine doesn't support it. Condolences
 
user1804599
Well, I can do foreach ($xs as $i => $x) and then check whether $i === 0.
 
7:58 AM
@not-rightfold Sounds better already
 
user1804599
Magic numbers. :|
 
user1804599
I suck at imperative programming.
 

« first day (1055 days earlier)      last day (3894 days later) »