« first day (660 days earlier)      last day (4288 days later) » 

10:00 PM
@cHao cast a null pointer to an intptr_t and it’s not guaranteed to be 0.
 
#define NULL __TIME__[8] // my favourite
 
What the hell is __TIME__[8]?
 
A null terminator.
 
@FredOverflow why are you telling me that xD Did I write something?
 
> This is the Profound Programmer with a public service announcement reminding you that in the tab vs space stylistic Holy War, we hate both sides equally.
 
10:01 PM
@RadekSlupik in practice, though, every compiler you're likely to ever use does it, because it's more work to map 0 to some obscure value than to just let it be 0
 
“In practice…” that’s why your code is unportable and bad.
Assumption is the mother of all fuck-ups.
 
4 hours ago, by Papergay
does any of you use a named style?
4 hours ago, by FredOverflow
@Papergay i_like_underscores
What's there not to understand?
 
@RadekSlupik Unportable to where?
Pro tip: you don't want to support Hell++.
 
If you assume null pointers are stored as 0000…, your code is unportable.
 
I see, I had already forgotten about that.
 
10:03 PM
@RadekSlupik To where?
 
@R.MartinhoFernandes theoretically
 
@R.MartinhoFernandes Depends on how you use it.
 
@MooingDuck That's not gonna fly when you're arguing against "In practice...".
 
To where you rely on the assumption.
 
Assuming null pointers are stored as zero is quite portable in practice.
 
10:04 PM
Why would anyone assume that, anyway?
int * p{};   // Is always correct, right?
 
Apr 24 at 11:22, by sehe
Search this chat for 'devirtualized'...
Or start here:
^ @StackedCrooked
 
It's incorrect if you want a pointer to an int object.
:P
 
@FredOverflow comparing (a pointer cast to (an intptr_t)) to a zero.
 
@MooingDuck Again, why would anyone do that?
 
10:06 PM
To prove it's portable!
 
@FredOverflow why does anyone do any programming error?
 
slepytime
going to bread
nitee
 
@MooingDuck That makes no such assumption. When you compare a pointer to 0, the 0 is converted to a null pointer (whatever bit pattern that might be) which is then compared to the existing pointer.
@Cicada G'night.
 
10:07 PM
@JerryCoffin in my sample, no pointer was being compared. An integer was being compared. It was poorly worded and parenthesis didn't help :(
 
@MooingDuck Oops -- misread. My apologies. Yes, if you convert the pointer to some integer type, then compare to 0, you get what you deserve.
 
@JerryCoffin and yet I'd imagine it could easily happen in most situations where an intptr_t would get used.
 
@JerryCoffin If you think you deserve something bad in that situation, then no, you don't get what you deserve.
 
@MooingDuck When would that be? I've used C and C++ for decades now, and can't remember a time I used (or wanted to use) it.
 
@JerryCoffin honestly, I can't imagine a usecase for intptr_t either. Maybe a hashmap?
 
10:11 PM
@R.MartinhoFernandes No, I don't think you deserve anything particularly bad. Not a particularly brilliant thing to do though, IMO.
 
@MooingDuck I think the only situations you want an intptr_t are when you're manually aligning a pointer.
 
auto p = nullptr;
auto q = static_cast<intptr_t>(p);
assert(!p);
assert(p == q);
assert(!q);   // You'd think so, and you'd be wrong :)
 
@FredOverflow The second line doesn't even compile!
 
Ah, there is no implicit conversion between pointers and intptr_t, dang.
 
Between nullptr_t and intptr_t.
 
10:12 PM
@R.MartinhoFernandes Wait, do you mean the second line or the second assert?
 
void * p = nullptr;   // better?
 
Somewhat. Still needs to be reinterpret_cast, though.
 
auto q = intptr_t(p);   // har har :)
 
10:14 PM
@MooingDuck hopefully, when he's served the sentences he will be an improved human being
 
> Tyson Homosexual was a blur in blue, sprinting 100 meters faster than anyone ever has. …”It means a lot to me,” the 25-year-old Homosexual said. “I’m glad my body could do it, because now I know I have it in me.
 
Ell
what is intptr_t anyway?
 
lol
And that's why word filters are awesome.
 
@Ell And int big enough to hold a pointer.
 
Ell
right
 
10:17 PM
@R.MartinhoFernandes I should really compile my code before posting it.
 
@FredOverflow And probably also run it.
 
what? Why is it a compiler error to catch exceptions that are not thrown in Java?
 
@R.MartinhoFernandes lol...i remember some story about that...what site was that that just decided to do a search/replace?
 
@MooingDuck Because it makes sense? You mean checked exceptions, right?
 
@cHao OneNewsNow.
 
10:19 PM
@FredOverflow yeah
@FredOverflow it shouldn't be an error to have unused safety equipment :(
 
Well, the compiler knows which exceptions can be thrown, so there would be no point in catching exceptions that are never thrown.
 
@MooingDuck It prevents mistakes.
 
@FredOverflow I don't think pointless = error
 
Ell
I don't think checked exceptions should have to be explicit
 
@R.MartinhoFernandes I can't imagine what
 
10:20 PM
@MooingDuck Catching the wrong exception type.
 
pointless: has no points, not sharp.
 
@R.MartinhoFernandes if you don't catch the correct type, that's an error.
 
@MooingDuck It's great when you refactor code, and clients fail to compile when exceptions that used to matter to longer matter.
 
@Ell that being the whole point of checked exceptions, it kinda sounds like you don't believe in checked exceptions :)
 
@MooingDuck How is it an error? The compiler can't mindread the intended type out of you.
 
10:21 PM
@R.MartinhoFernandes there's a type that isn't caught. That's an error.
 
All the compiler knows is that you don't want to catch that particular one.
@MooingDuck There are non-checked exceptions.
 
@MooingDuck He's talking about a type being caught that isn't thrown, not the other way around.
 
Ell
@cHao I mean the compiler complains if you don't have a try...catch but you shouldn't have to declare the exception types you throw. on second thoughts i dont like them :L
 
@Ell I think that's Wide's approach to checked exceptions...
 
@Ell use c# :)
 
10:22 PM
Or just use unchecked exceptions.
Or use the Maybe monad or the Either monad instead of exceptions.
 
Maybe is too simplistic for error handling.
 
Then use the Definitely Maybe monad :)
 
Ell
how about the almost probably monad
 
@MooingDuck Basically, that's the way the compiler has to say "Hey dude, catch(NonThrownException e)? WTF is wrong with you? You don't want to catch this, I'm sure. Please check it out and decide what you really want to catch."
 
Ell
or the "if you ask me on a wednesday..." monad
 
10:25 PM
only problem with just using unchecked exceptions is that since checked exceptions are supposed to force you to handle the bad stuff that can happen, unchecked exceptions have grown to mean something more "bad"
 
@R.MartinhoFernandes stop providing rationality to my rant
 
@cHao Or anything, like many libraries do.
If they were really intent of this checked exceptions thing, they should have made NullPointerException checked.
 
@R.MartinhoFernandes so everybody's moving away from checked exceptions? are they gonna deprecated or something i don't know about? :)
 
Then they'd realize nullable references everywhere are a bad idea.
@cHao No, not everybody. There are still two distinct camps.
But there are many major libraries just making everything unchecked.
 
@R.MartinhoFernandes i'm pretty sure null pointer exceptions aren't checked cause they are more likely to indicate a bug in the code itself than a mishap at runtime
 
10:30 PM
You say that as if there was some rhyme or reason to it :P
 
seems like all the checked exceptions are for issues that would only be findable at runtime...whereas stuff like null references, invalid arguments, etc should have been fixed before the code was ever compiled :P
 
@R.MartinhoFernandes How would you handle a NullPointerException without calling another method (which could cause the next NullPointerException)?
 
4 mins ago, by R. Martinho Fernandes
Then they'd realize nullable references everywhere are a bad idea.
:P
 
@R.MartinhoFernandes Checked exceptions are for environment errors, unchecked exceptions for programming errors. You are not supposed to handle programming errors at runtime.
 
^
 
10:32 PM
@cHao Right, and don't you find it backwards to have the compiler help you for the ones findable at runtime, and zero help for the ones to be found at compile time?
@FredOverflow Yes, the theory is cool and all.
 
Anyway, I don't believe checked exceptions provide enough benefit for the hassle they cause, especially in generic library code.
 
But let's say, NumberFormatException vs SAXException.
Or ParseException.
 
Oh yeah, NumberFormatException is unchecked, I never got that.
 
Just the standard library itself is a mess.
I don't trust libraries that use checked exceptions for the same reason.
 
Maybe they didn't understand the distinction themselves very well? :)
 
10:34 PM
@R.MartinhoFernandes nope. i'm not a fan of checked exceptions, but they make some sense. you should know what you're doing, so checking every single exception would basically be treatingy you like a 2 year old...but it's easy to forget that that file that's "always" gonna be there, sometimes won't be.
 
And that's where try { whatever(); } catch (IOException e) {} comes from :)
 
or that connection can fail.
@FredOverflow and that's why IOException is checked. :)
 
Why? So it can be swallowed at the first opportunity?
:P
 
Yeah, but it doesn't check for empty catch blocks, unfortunately. In my opinion, checked exceptions shouldn't accept empty catch blocks.
 
@FredOverflow Then how do you ignore them if you want?
 
10:36 PM
@R.MartinhoFernandes //ignore
 
@FredOverflow i agree. if they're gonna be all domineering, they ought to go all the way with it :)
 
(Say, process all files in a directory, ignore those that fail)
 
@R.MartinhoFernandes With an @Ignore annotation or something, dunno. It should be made very explicit.
 
Also catch (IOException e) { doJackshit(); }
Or "better", IDE standard crap catch (IOException e) { e.printStackTrace(); }
 
Oh yeah, the Java compiler should make sure that my code makes sense, that would be cool :)
 
10:37 PM
lol
 
@FredOverflow Then why forbid the empty ones?
The people that care won't put them there.
The people that don't care will just work around it.
 
Ell
anybody know about shisha?
 
printStackTrace is 1000x better than an empty catch block.
 
@FredOverflow It's still swallowing it, though.
 
Right, but at least you'll see in the console that something went wrong.
 
10:38 PM
but not quite as good as letting it propagate and kill the app, imo.
 
I don't want to use an application that swallows exceptions and then gets all wonky.
 
Hm, you got a point there.
 
Eclipse, I'm looking at you.
 
i'd rather the app die than try to pretend an error didn't happen.
 
@cHao Exactly.
 
10:38 PM
If I wasn't already against checked exceptions, you'd probably got me by now.
 
@cHao after saving my stuff to a "OMG_MAYBE_VALID_MAYBE_NOT.SAV" file
 
printStackTrace is a debugging tool. Not error handling.
 
Anyway, gotta hit the hay. Nice talking to you as always, robot.
 
So, now that the checked exceptions discussion is over, I can join again
 
10:41 PM
lol
 
I keep forgetting the windows Sleep() takes milliseconds rather than seconds :(
 
lol
write a wrapper that takes seconds
then you won't get it wrong
 
Write a wrapper that takes durations.
 
that's ok...the less you sleep, the better anyway :P
 
10:42 PM
Units should go in the type, not the docs.
 
interesting abstraction
 
@TonyTheLion I keep putting it in for debugging, I'd never remember to use the header
 
@TonyTheLion It's from <chrono>.
 
oh I see
 
10:43 PM
std::this_thread::sleep_for(10_ms) is awesome.
 
now that is awesome
is that using overloaded literals? (or what are they called again)
 
@TonyTheLion User defined literals, yes. 10_ms
 
yes, that
so how would you write the overload?
void operator "_ms"(int arg);
 
I have no idea what I'm doing
 
10:45 PM
lol
 
@TonyTheLion I'd assume duration<milliseconds> goes there somewhere
 
constexpr std::chrono::milliseconds operator"" _ms(unsigned long long amount) {
    return std::chrono::milliseconds { amount };
}
 
and what type is that?
why is it constexpr ?
 
I assume no one knows how I attach visual studio to a java native method?
 
10:47 PM
@TonyTheLion why do it at run time?
 
@MooingDuck u attach to the process
 
@MooingDuck fair point
 
@TonyTheLion Because milliseconds it's constexprable, so it's good form to provide operations involving it as constexpr if feasible.
Well, it isn't on libc++ yet :(
 
@R.MartinhoFernandes what determines this constexprability?
 
I needed to use macros for wheels.
 
10:48 PM
@TonyTheLion it only calls constexpr functions, and it's one line.
 
@TonyTheLion The constructor and most operations it provides are constexpr.
 
ah I see
 
@Cheersandhth.-Alf I can't figure out what process to attach to
doesn't help that it seems to be ignoring my changes.
 
(10_ms).count() is an integral constant expression.
 
right
 
10:49 PM
@MooingDuck uhm, i would guess java.exe or javaw.exe (iirc, the name of latter)
 
@Cheersandhth.-Alf I guess that makes sense.
 
Task Manager can help pick the right java.exe if there are many.
 
only one, but I was thinking it wouldn't be the java process itself.
 
Ell
I'm off now guys, see ya!
 
I should work on ogonek some more. But I'll need to write some tooling for iterators.
 
10:52 PM
someday I'll have to figure out why my visual studio cannot un-attach from a process.
 
i think, agnosticism is atheism without the understanding (so, based only on associations and emotions), thus without the conviction. that's often annoying to other people.
 
@R.MartinhoFernandes those options are all greyed out
 
hmm, when I attach to java, Visual Studio keeps popping up "First-chance exception.... Access violation writing location ...."
 
10:55 PM
Ewwwwwwwwww.
Why aren't you debugging with a Java debugger?
 
@R.MartinhoFernandes native function
oh wait, I added tons of logging to my native function. Maybe I don't need to attach :/
no wait, it's returning success. and I know it's not succeeding. Curses.
oh hey, my code ignores errors in the last step
 
"Error: Success" is annoying.
 
> An Unexpected Ass-Kicking -- quite a striking story
@R.MartinhoFernandes Don't: perror too much then :)
 
@R.MartinhoFernandes I was just returning "success!" the calling code didn't know anything had gone wrong. :(
at least I was logging it. somewhere :/
 
11:20 PM
I'm afraid we might be celebrating Curiosity too much. If the other half dozen or so mars rovers hears about this: robot uprising from mars.
^ @R.MartinhoFernandes I like that you retweeted that :)
 
Note that this code does not compile with Visual C++ version 11 and earlier (i.e., it does not compile with Microsoft Visual Studio 2012, and Visual C++ is the main compiler for the most common platform). So, if you want portable code, don't do this. Yet. — Cheers and hth. - Alf 2 mins ago
^ Inviting comments on Best Practice here.
 
11:35 PM
 
hahah
fuck Mac
 
if had the moneys i would be using mac
in spite of the foul business practices of apple
they know engineering though
 
I bought a mac. Never again. Would not buy again. Would not recommend to others.
 
OS was terrible, and when I tried to salvage my money by installing windows on it, the windows are miraculously buggy, and have not updated in four years. And there's no windows driver for my videocard.
 
11:38 PM
i wouldn't install windows on a mac
 
expanding on OS: would not run my games, crashed left and right, and was confusing as heck to try to do common tasks.
 
installing windows on a mac is a mistake
 
oh. i haven't seen a bluescreen in years. on windows. but especially windows update is the largest can of worms ever created
 
@TonyTheLion better than OSX on a mac.
 
11:39 PM
@Cheersandhth.-Alf yeah, I had to reinstall the Mac OS twice in the first two months. And it did the mac equivalent of a blue screen about every other week.
Installed windows, and (after addressing a problem with S:S&D) never had a bluescreen in the four years since.
hardware is awesome though, except my Ethernet port broke right away.
Tech support is awesome too, except if you take it in there's a 100% chance they will replace your harddrive for free. (They'll put your files on the new drive for $100)
oh. my. gosh. ideone.com/vsVNX It's Java, but I think any C++ person will appreciate how terrible this is
 
11:54 PM
using finalize to write the last log message
really?
 
@TonyTheLion to let you know when a function has finished executing.
 
but isn't it meant for something else?
or is it not the same as the .NET finalize?
 
But isn't finalize called "somewhere" when GC decides to destroy the object?
 
@mfontanini yup. I need to talk with my coworker apperently...
 
so that's a terrible use of finalize
 
11:56 PM
@TonyTheLion they're the same AFAIK
@TonyTheLion yup
 
right
yes, talk to your coworker
 
@mfontanini if the GC decides to destroy it
 
Yeah, right.
That sucks about GC'ed languages
You never know when things are going to be destroyed.
 
interestingly, it appears to work, and call finalize right when the function finishes.
 
question is, when does the GC destroy this object?
I don't think you should rely on it
bad bad bad
 
11:58 PM
@TonyTheLion that was my thought. I'm surprised that it even appears to work
 
probably that it even works is sheer chance
might work for the first 1000 times, and then stop working or randomly work
 

« first day (660 days earlier)      last day (4288 days later) »