« first day (1865 days earlier)      last day (3076 days later) » 

Ell
11:04 PM
Hmm. I only want to highlight trailing whitespace as erroneous if it is past the current indentation level
 
Why does g++-4.8 refuse to construct any std::regex with brackets ([]) in it?
 
std::regex was only added in GCC 4.9
 
Ell
nvm rapptz is god
 
@Rapptz Ah
Why does it exist at all, then?
teethgrind
 
95
A: Is gcc 4.8 or earlier buggy about regular expressions?

Jonathan Wakely<regex> was implemented and released in GCC 4.9.0. In your (older) version of GCC, it is not implemented. That prototype <regex> code was added when all of GCC's C++0x support was highly experimental, tracking early C++0x drafts and being made available for people to experiment with. That allow...

 
11:14 PM
Ah, cool
Cheers
 
Releases are so wordy
More words than code
 
fuck
I think I threw away some of my pills by accident
 
guys
ask me any of your suspicions
I am a licensed confirmologist
 
I saw some new people in tavern a while ago. Didn't discover their motivations until the start of mod election a few weeks ago. Now both new regulars in Tavern have become the mods.
 
never mind, found em
 
11:23 PM
@chmod666telkitty goh how evil and noteworthy
people who become the moderators are the ones that are commited and trying ?!
please do report to the press immediately
 
Ell
c is a pain for cleanup on exit
 
s/ for cleanup on exit//
 
Ell
yup
 
@ScottW because it's a good alternative chat to the lounge here ... Since I am routinely kicked from here FOR NO APPARENT REASONS ALL THE TIMES!!!
 
@Ell hear me out
there is this one magical fruit
the forbidden fruit, some will say
but you must listen to me, and ignore the cargo cult
for proper error handling with cleanup in C, use goto
2
 
Ell
11:29 PM
that's not even good man
I would need to have a label for each resource I need to cleanup, right?
 
@orlp I support that.
 
@Ell yes
it's not good
 
@Ell Depends, you might do it that way or you could just check if (fd != -1) close(fd); or similar.
 
but it's a lot better than the total drama that you'll get if you're a cargo cult programmer that'd rather die than use goto, because that's what he read
 
Ell
@orlp I suppose
 
11:31 PM
@orlp Not necessarily
 
@orlp \o/
 
@CatPlusPlus right, in some cases you can merge some labels into one
 
Should be doable in most cases if not all
 
Ell
I haven't attempted it yet
I just reordered code and realised in this particular case it wasn't so terrible
I should refactor before I speak
 
Why are you writing C?
Nevermind, I know the answer to that
 
Ell
11:34 PM
:3
 
@Jefery I'll bite. Why?
 
Probably school. That's the answer to most "Why are you doing <stupid thing>?" questions.
 
@Jefery Oh. Boring.
 
@orlp Is this a joke?
 
Ell
@Jefery No
 
11:36 PM
Why would that be useful?
 
Ell
you can have a section of code labelled which does all the cleanup
 
If I ask real nicely, can I please have the 'Lacks Minimal Understanding'-close-reason back, pretty please? sigh
 
Ell
so you only have to write cleanup once and then do goto cleanup
I tihnk that's the traditional use
 
@Ell Why is it better than say a function?
 
Ell
because you'd have to have a function for every combination of resources
cleanup(FILE*, int*, int**, char*) for one function
 
11:39 PM
Wait, what?
 
Ell
and cleanup(const char*, int*, FILE*, FILE*) for another
for example
unless I have misunderstood
 
Maybe I'm misunderstanding
@Ell What would that function do exactly?
 
Ell
@Jefery free the first two pointers, close the latter two filestreams
What did you mean by a function?
 
void free(RESOURCE*)
 
Ell
Oh yeah you do that of course
but under the cleanup:
you "call the destructors" in reverse order after your cleanup label
and you can then goto it from anywhere in the function
I think that is the way you're supposed to do it, don't quote me though
 
11:41 PM
16 secs ago, by Ell
I think that is the way you're supposed to do it, don't quote me though
 
Ell
:O
:(
 
@Ell I see. I think.
 
int main(int argc, char** argv) {
    char* buf = malloc(100);
    if (!buf) goto exit;
    FILE* f = fopen("test.txt", "r");
    if (!f) goto cleanup_buf;
    // ...
cleanup_f:
    fclose(f);
cleanup_buf:
    free(buf);
exit:
    return 0;
}
 
user406009
WTF, who puts private methods in interfaces?
 
user406009
Some people ...
 
11:43 PM
@Jefery this is just an example - but this is a scalable approach
 
1 min ago, by Jefery
16 secs ago, by Ell
I think that is the way you're supposed to do it, don't quote me though
@orlp I might even prefer to use a with_file kind of approach, even though C is shit.
 
^
 
C doesn't have lambdas (well not standard C anyway)
So execute-around is not feasible
 
that's the "even though" part.
perhaps you could do some terrible xmacro trickery.
 
Nah
Closing over things is important to build up a context
 
11:46 PM
Lambda closing is not necessary if you have partial application
 
effectively, you're implementing closure lambdas that can only be called in strict nesting, and return by falling through, or return early by goto
 
user406009
@CatPlusPlus Couldn't you just use void* for the context?
 
@Lalaland To do what
 
user406009
You can "close" over things by casting them to void* and passing them in.
 
Passing them in how
 
11:50 PM
@Lalaland but this is not scalable
you have to manually pass in every context item
 
VA is extremely limited and there's not much you can do with va_list
 
as you nest contexts this is O(n^2) work for the programmer
 
user406009
Well, you have a void* parameter for any function which takes a function pointer.
 
It's really just not feasible to do in C, even if possible
 
the goto method is by far the sanest way I know of to do structured resource management in C
if it doesn't pass your code review just because it has goto in it, your standards of judging code suck
then there's another valid use of goto: breaking multiple nested loops without introducing all kinds of flag variables
 
user406009
11:53 PM
I would argue that goto has a severely diminished role in C++ though.
 
user406009
And breaking out of nested loops can also be done with return.
 
@Lalaland this depends on the context
but if possible, yes, return is cleaner
but it's not a catch-all that should always be used instead of goto
 
user406009
Yes. Use the right tool for the right job.
 
user406009
It's sorta like using raw pointers. Sometimes (but not often), they are the right tool.
 
Bah. I need some ass kicking. I should have been in bed sleeping an hour ago.
 
Ell
11:57 PM
me too
 

« first day (1865 days earlier)      last day (3076 days later) »