« first day (495 days earlier)      last day (4452 days later) » 

10:00 PM
> Fix the bugs in your code and the mystery will go away. Broken code does strange things, that's the way it is. – David Schwartz 2 mins ago
 
@daknøk Did you ever pluck a usb stick into your mac?
 
I really like David's approach to these UB questions.
 
@FredOverflow only into the keyboard.
 
A program that exhibits UB is a bug, there's no way around that.
 
@daknøk Haha
 
"XD", "nice", "Haha", star count: zero.
2
 
You're begging!
 
@RMartinhoFernandes Reminds me of the badly-chosen name "experts-exchange".
 
Did you mean: expert-sexchange.
Cue Tony arriving.
 
HYPHENATED SITE NOOO D:
 
Xeo
10:03 PM
@CatPlusPlus Or @Kerrek's secret-sexchange
 
@daknøk Onebox it
 
@KianMayne onebox what?
 
3
A: rand() generating same number upon compilation

Adam STry adding srand(time(0)); at the beginning of main.

 
I'm fixin' up my trajectory plotter so I can post it in the project wiki :D
 
Do you agree with my update?
 
10:04 PM
@KianMayne The image?
 
@FredOverflow Totally.
I'm posting a C++11 solution in a while.
 
@daknøk Yeah I star that kind of thing
 
@FredOverflow One seed per program run, definitively. Can't have it any other way what with rand being program-wide.
 
@KianMayne not sure if that's such a good idea.
 
Reseeding generator can be valid.
 
10:06 PM
/dev/random ftw
 
Don't deplete my /dev/random for trivial stuff, please.
 
@RMartinhoFernandes Good. I updated a few other answers in a similar fashion :)
 
@daknøk /dev/urandom or /dev/frandom
 
ARstjghejukgersdsag What's wrong with ideone?
 
@CatPlusPlus And I wish I knew how to do entropy analysis, or even what's the right name for that.
 
10:07 PM
Doesn't /dev/urandom use the same pool?
 
@RMartinhoFernandes It's offline for me right now :(
 
@RMartinhoFernandes C++11 solution: srand(time(nullptr))
 
Xeo
> It's not just you! ideone.com looks down from here.
 
@CatPlusPlus not IIRC - or it might be OS dependent
 
10:08 PM
@Xeo We have so much in common ;-)
 
@daknøk oh. my. god
 
@daknøk lol
 
Xeo
@daknøk Yes - err, what?
 
@daknøk Nope.
 
@sehe I'm J**aing sorry.
 
10:08 PM
After "C" and "C with classes", we finally have "C with classes and nullptr"!
 
Jucaing?
 
Javaing :)
 
Java apparently.
 
evening
what's happening fellas?
 
J**a is the new bra*nfuck.
 
10:09 PM
Oh wait, std::srand(std::time(nullptr))
brainjava
 
@daknøk All of my upvotes.
 
39 mins ago, by R. Martinho Fernandes
Like some books out there are "updated for C++11" by showcasing nullptr in strtok examples (I am not making this up).
 
sbi
6 mins ago, by Cat Plus Plus
Cue Tony arriving.
 
@sehe I think it was a play on that.
 
Xeo
6 mins ago, by Cat Plus Plus
Cue Tony arriving.
 
10:10 PM
@TonyTheLion Goodfellas! I finally remember the title of that movie now. Thanks!
 
@daknøk srand(time(strtok (nullptr," ,.-")));
 
Xeo
Dammit, @sbi. :(
 
sbi
@Xeo :b
 
huh?
oh noes, I arrived exactly at the wrong damn time
 
@sbi @Xeo lol
 
10:10 PM
@Xeo How did he know?
 
happens every. damn. time.
 
sbi
@TonyTheLion 6mins ago someone said something which made us expect you to arrive. You did.
 
Haha.
Called it.
 
36 mins ago, by FredOverflow
struct boobs { void operator()(){} }; boobs()();
 
NOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
 
10:11 PM
8 mins ago, by Cat Plus Plus
Cue Tony arriving.
 
Xeo
@FredOverflow It was the expert-sexchange
 
sbi
@TonyTheLion And it's not because we're on that subject all the time. It hadn't been mentioned in hours.
 
what is this?
 
@CatPlusPlus you have everyone's schedule planned out don't you ;)
 
calm down. there is no link to another page. No risk of getting lost in the boobs
 
10:11 PM
@FredOverflow I'm 12, what are boobs?
 
it seems @Cat knows me better than I do
 
sbi
@daknøk You drank from them recently.
 
@daknøk closely related to babes
 
@daknøk The lounge is not appropriate for 12 yeard olds, please leave.
 
Xeo
10:12 PM
@sehe Now there is.
 
I read boobs
 
@daknøk you are 12 and don't know what boobs are, and yet you show me a picture of a mac user having $3X with his computer? Silly XD
 
oh noes, and now tvtropes
 
@Hoxieboy :P
 
you guys, are worse than my family
 
10:12 PM
@Xeo bin all the links
 
A booby is a seabird in the genus Sula, part of the Sulidae family. Boobies are closely related to the gannets (Morus), which were formerly included in Sula. Description Boobies hunt fish by diving from a height into the sea and pursuing their prey underwater. Facial air sacs under their skin cushion the impact with the water. Boobies are colonial breeders on islands and coasts. They normally lay one or more chalky-blue eggs on the ground or sometimes in a tree nest. See also Booby Mating Dances Name Their name was possibly based on the Spanish slang term bubie, meaning "dunce", as...
 
not that they have tv tropes links
 
@TonyTheLion they seem to know your weak spots
 
@sehe been here too long
but anyways
 
10:13 PM
@Hoxieboy What is $3X? A monetary amount between 30 and 39 dollars?
 
@RMartinhoFernandes lol
 
For a moment there, I considered moving the TVTropes link to the Java room.
 
@Xeo no there isn't
 
:2733331 why do I click links before looking at them? I trust you guys too much
 
@FredOverflow that, or an encrypted term for "sex"
 
10:13 PM
@RMartinhoFernandes you should've done it
 
@RMartinhoFernandes move it to the php room instead
 
why did you move the Tropes link to the bin anyways?
scared to click it? :P
 
@MooingDuck why do you link non-existant messages :)
 
To break Duck's attempt to reference it, obviously.
 
@sehe Translate "ik geef mijn varken een vogel" to English and pronounce it.
 
10:14 PM
"Gibberish".
 
@daknøk I give my pig a bird
 
@daknøk I feed my pig a bird (or I hand it one)
 
@sehe p.s. use "give"
 
Just it didn't look like it pointed anywhere
 
10:15 PM
@daknøk Nope :)
 
chuck testa
 
@sehe arrr then you don't get it :P
 
Can we put D projects on the wiki? :D
 
@daknøk oh, I get some, alright!
 
If you watch the whole video, I will give you a cupcake: youtube.com/watch?v=gkfVdrtLcRs
 
10:16 PM
@Hoxieboy I have that song in my iTunes library.
 
"Their name was possibly based on the Spanish slang term bubie, meaning "dunce", as these tame birds had a habit of landing on board sailing ships, where they were easily captured and eaten. " Knowledge +1
 
@Maxpm Not every C++ programmer appears to like D.
 
@FredOverflow But they all do?
 
I hate D, it's got GC.
 
@Maxpm sure, but you may be mocked
 
10:16 PM
@FredOverflow Not every C++ programmer likes C++.
 
@sehe I think @DeadMG hates D.
 
@daknøk Newsflash: C++ 'sgot' GC too (it got specs for it and implementations, though no conforming ones, I guess)
 
If you like C++, you haven't coded in it long enough
someone said that here once
 
@daknøk You can manage memory manually, if you so choose.
 
@Maxpm that's a hell in D.
 
Xeo
10:17 PM
@Maxpm You can't use Arrays then, IIRC
 
@Maxpm But if you choose so, you can't use the standard library. Or arrays.
You can't use D without GC. (I don't really see a big problem with that btw)
 
@sehe the standard allows for it. Garbage collection is implementation defined in C++11. But programming in C++ without GC is reasonable. In D it isn't.
 
you guys have all used D?
 
@RMartinhoFernandes You can always replace the standard library with blackjack and hookers.
 
@daknøk there's one that strikes the balance. +1
 
10:18 PM
oh hookers
 
@TonyTheLion double D
 
boobs?
 
> The program can explicitly inform the garbage collector that an object is no longer referred to (with the delete expression), and then the garbage collector calls the destructor immediately, and adds the object's memory to the free storage. The destructor is guaranteed to never be called twice.
 
@TonyTheLion I've played with D in its 0.x days.
 
So, you can use new and delete just like you always have.
You don't need to turn garbage collection off altogether.
 
10:19 PM
But you cannot use RAII with classes in D, right?
 
@Maxpm I don't use new and delete.
@FredOverflow There's a scope thingy.
 
@RMartinhoFernandes ^ This.
 
Shared putters are GC.
 
@ScottW oh. shame he did it in French. Let's ask him to an English version so we can enjoy it :)
 
@RMartinhoFernandes What does the scope thingy do exactly?
 
10:20 PM
@FredOverflow RAII.
 
RAII is simple GC scheme, too.
 
@CatPlusPlus Depends on your definition of GC. Some say reference counting is GC, some say it isn't.
 
@FredOverflow It deletes an object as soon as it goes out of scope, rather than letting it stick around for the next GC pass.
 
It's automated memory management.
 
The thing I don't like about GC is that you don't know when things will happen. You acquire a resource but you never know when it's freed.
 
10:21 PM
@ScottW He could do a quantitative language benchmark: see what language has the most efficient verbal numeric system
 
@Maxpm But class objects have no scope in D?
 
@FredOverflow It's also a bit more flexible: d.digitalmars.com/2.0/exception-safe.html
 
@FredOverflow I don't know what you mean.
 
With regards to the memory itself, you don't need to know when things will happen.
And with GC you get more functional closures and stuff.
 
@Maxpm When you say Foo* p = new Foo; then the object pointed to by p has no name.
 
10:22 PM
All languages designed to work with GC now include some scheme to deal with deterministic resource management.
 
I saw how closures are implemented in the Lua VM, that shit scares me
this was in C too
 
@FredOverflow Do scope p = new Foo; instead and it becomes similar to auto p = make_unique<Foo>();.
 
Python has with, Java has try (...), C# has using.
 
@FredOverflow Right...?
So if one does not use raw new and delete, why would one care about a garbage collector? Performance concerns?
 
@RMartinhoFernandes cool
 
10:23 PM
@FredOverflow No idea.
 
@CatPlusPlus Yep, that's all languages! (Just kidding.)
 
Okay, not all.
Most.
I wanted to say most.
 
@Maxpm Because with GC, you can say T instead of std::shared_ptr<T>, and allocation can be a lot faster with GC.
 
@Maxpm That is one use case of GC yes.
 
Factor and Lisp both use with-x idiom, usually.
Factor even has generic with-destructors.
 
10:24 PM
@SethCarnegie My weekend starts a day early this week. Ping me the link your Clang on Windows instructions.
 
@CatPlusPlus Does that Python with looks Lisp-ish, too? I don't remember what it looks like.
 
@Mysticial ...and your weekend just disappeared completely :)
 
with expr [as name]:
 
@FredOverflow Why?
@RMartinhoFernandes thx
 
10:25 PM
Where expr evaluates to context manager (object implementing __enter__ and __exit__ methods).
 
@LucDanton here is a python example of with for file IO:
with open('file.txt', 'r') as F:
	F.read()
 
That as name is weird, but okay.
 
I am referring to many C++ programmers' hostile reactions towards D's garbage collection. Out of all of D's features, garbage collection should be one of the least controversial. Is it just their natural aversion to change?
 
Lisp's with-x is a function/macro that takes a function as an argument, and wraps it with the management code.
@LucDanton __enter__ can return something, and then you can bind that something to a name with as foo
 
@Maxpm people often conflate GC with "lack of deterministic resource management". And so, C++ programmers read "GC" as "taking RAII away"
 
10:27 PM
BUT GC IS EVIL AND ALL, but oh hey, you should be using std::shared_ptr there.
 
@CatPlusPlus Is as used elsewhere? Perhaps I'm just weirded out because it's not familiar to me in Python.
 
@CatPlusPlus what would be the equivalent in C++ instead of python for that with statement?
 
In exception handling. except (A, B) as e:
 
@Mysticial Getting stuff to work on unsupported platforms tends to fill up your weekends.
 
Well, that does look consistent. Ish.
 
10:29 PM
Old syntax was except (A, B), e and everyone got it wrong.
 
@jalf "RAII" referring to deleting objects when they go out of scope? But, it's not like the language lets you refer to those objects. Who cares how long they stick around in memory?
 
@Maxpm It's about determinism.
 
@CatPlusPlus except A, e and then when using e it's not the expected one?
 
@Maxpm RAII is about more than just memory.
 
Memory is just one resource.
 
10:29 PM
@Maxpm Memory isn't the only resource you need to handle.
 
@LucDanton except ExceptionA, ExceptionB: bound exception object to ExceptionB instead of catching both exception types.
 
@CatPlusPlus They are worried that their program's behavior will vary from session to session because of garbage collection?
 
You have to use parentheses there.
 
@TonyTheLion What are you laughing at?
 
10:30 PM
@FredOverflow I've got an extra machine sitting around... So it shouldn't get in the way of my normal stuff... I'm also quick to give up if that helps. :P
 
@Maxpm They are worried their files won't get closed when they should be.
 
just your guys conversation about D
 
I think it's time for D++.
 
Some resources need deterministic handling.
 
and this ^
 
10:31 PM
@TonyTheLion I thought you were laughing about how three guys said almost the same thing about RAII.
 
Memory you can release later, that's not a problem.
 
holy sh*t lol apparently when trying to set pixels to the screen in python, after following a trajectory (to look like an explosion) it overloads the program and makes it stop, ima have to work on that XD
 
@daknøk Let's cut the bullshit and jump straight to Z.
 
@FredOverflow what about ß?
 
@FredOverflow have you ever heard of the band "Five Finger Death Punch" ?
 
10:31 PM
And managed heaps usually don't release memory anyway.
 
@TonyTheLion they seem to be very good.
 
@CatPlusPlus Altough the more memory you use, the less likely your cache hits.
@TonyTheLion no
 
@daknøk I quite like them actually
 
@TonyTheLion will listen
 
@FredOverflow check them out, not bad actually
 
10:32 PM
@FredOverflow It's more related to data layout and hotness than actual amount of used memory.
 
Quite nice.
 
@CatPlusPlus I'm getting lost in the jargon. What is RAII "about," then?
 
@CatPlusPlus Layout and hotness sounds like you're talking about something else :)
 
10:33 PM
@Maxpm Deterministic resource handling.
Destructors running at predictable times.
 
@CatPlusPlus "I'm getting lost in the jargon."
 
@Maxpm RAII is about releasing any kind of resource 1. deterministically and 2. safely (in the face of exceptions).
 
@Maxpm rely on the scope to control resource allocation, by allocating and deallocating in constructor/destructor of an object.
 
@CatPlusPlus you seem to be in a minority here.. everyone else thinks it's about sex
 
today I came to the conclusion that it's really hard to write software that always works.
 
10:34 PM
@je4d Not my area of expertise.
 
{
    // assume C++ RAII
    lock l(some_mutex);
    blah();
    // lock gets released here
}
{
    // assume GC
    lock l = new lock(some_mutex);
    blah();
    // lock doesn't get released here
}
3
 
@TonyTheLion You mean like a main function with an empty body?
 
@Maxpm When the resource "manager" goes out of scope (for whatever reason) the resources are released properly)
 
@FredOverflow That can fail, too, sadly.
 
@RMartinhoFernandes it might get released there, but you can't be sure.
 
10:35 PM
Bad maths on my part?: dl.dropbox.com/u/55158593/maths.png
 
@CatPlusPlus Assume no static objects with dynamic initialization ;)
 
RAII - Really Awesome .... (something about sex)
 
Missing DLL!
Some random CRT failure.
 
@RMartinhoFernandes But destructors are just supposed to clean up. They shouldn't have any important "unlock" logic in them, anyway.
Right...?
 
@FredOverflow Out of PIDs!
 
10:35 PM
@TonyTheLion II is the roman numeral for 2, so RAII means "really awesome 2".
 
@TonyTheLion Really Awesome Inter***se Interlude.
 
@Maxpm Where did you read that? One of Herb Schildt's books?
3
 
I think @ScottW wins :)
 
@Maxpm They do in RAII, because you know that a) they will run b) when they will run.
 
@Maxpm The lock must be released immediately. Otherwise the next pass through that code will block until the GC runs. Or worse, some other code will deadlock.
 
10:36 PM
@FredOverflow Zing!
 
@RMartinhoFernandes Can there be a new process if there's no more PIDs? If there's no new process, did your program really exhibit a bug?
 
@Maxpm as I see it, unlocking is cleanup - it's putting the state of the locks back how they were when you found them
 
Hmm.
@FredOverflow I don't know who that is.
 
@Maxpm good
 
@Maxpm No, they are supposed to clean up in the broad sense of the word. Unlocking a lock you acquired earlier is how you clean up a lock. :)
 
10:37 PM
@Maxpm RAII means clean up => release resources. Lock => resource. Do math. Succeed.
 
Releasing allocated memory is how you clean that up. Closing a file handle is how you clean up a file handle. :)
 
Aah, I see.
 
so yes, destructors are supposed to have unlock logic :)
that's basically what makes them so useful
 
@jalf I keep reading unlock magic.
 
@Maxpm the point is, deterministic cleanup (i.e. cleanup that you can tell when happens) is something you need. GC without deterministic cleanup is silly.
 
10:38 PM
Unmagic lock.
 
@Maxpm that's that destructors are for. What else would they clean up?
 
So the important part is not Resource Acquisition Is Initialization, so much as it is Resource Abandonment Is Deallocation.
 
lock l = new lock(some_mutex);
try
{
    blah();
}
finally
{
    l.unlock();
}
 
takes a bit of getting used to, because it means things happen "invisibly" (when an object goes out of scope, it does stuff), but it's very, very powerful
 
@Maxpm Yes, RAII as a name sucks.
 
10:39 PM
@Maxpm yeah, it's a stupid name
 
@Maxpm Yeah, RAII is a terrible name :)
 
That's why you don't use finalisers in GC to cleanup.
 
@ScottW if ever
 
@RMartinhoFernandes you can remove the stickied comment about clang now
 
@FredOverflow Try that in Java 6, with files (hint: close() throws a checked exception)
@SethCarnegie Ok. Done.
 
10:39 PM
@Maxpm Resource management by deterministic deallocation.... That's what it really means..... RMDD
 
@ScottW The Java language specification does not guarantee that finalizers are run at all.
 
@jalf I think Stroustrup said he was having a bad day when he came up with that one (@ Going Native)
 
Did anyone even see my image that I posted? XP
 
No language designed with GC in mind guarantee finalisers to run.
 
@je4d Ah, I didn't realize he was the one who came up with it
 
10:40 PM
Then I guess it's good that D has a scope qualifier.
 
I never even understood the point of finalizers
 
@RMartinhoFernandes What's the usual workaround to that? Switch to Java 7?
 
@jalf at least, someone said that about something at GN.. and I think it was stroustrup about RAII :-)
 
@TonyTheLion Last-effort cleanup.
Safety net just in case.
 
@LucDanton Configure your editor to add throws Exception to all method signatures.
 
10:40 PM
@je4d I think he assumed at the time, RAII implies the matching RMDD...
 
after the GC has done it's thing already?
 
Finalisers run when GC destroys the object.
 
I hate finally
 
@RMartinhoFernandes I'm not familiar enough with Java to know if that's sarcasm or not :(
 
So it can check if the resource was released, and do it if not.
 
10:41 PM
and you can write the finalizer yourself?
 
@FredOverflow Ah, so that's why the absence of finally is considered to be a RAII thing.
 
But it's not something you rely on.
 
@Mysticial it doesn't really matter now, rubenvb offers prebuilt (and more up to date) versions, but if you just want to for the fun of it: pastebin.com/txtRAL8m
 
The only marginally similar thing in managed code is use and dispose.
 
@Maxpm but the nice thing with RAII is that the user doesn't have to think about it. You create a lock object (for example), and it takes care of unlocking automatically. With C#'s using or other language's equivalent, the user has to specify "I want the Dispose() function to be called on this object as soon as it goes out of scope"
 
10:41 PM
@ScottW The idea "run a special method before an object gets GC'ed" sounds really simple, but in reality, it's basically an unsolved problem. You won't really "get it" until you implement your own GC.
 
@Xaade yeah, it's one of those great names that only make sense once you already understand the concept
 
@LucDanton It's both sarcasm and not. It basically amounts to disabling checked exceptions, and it's actually something you will find commonly in the wild.
 
@FredOverflow what is the problem with doing that
 
1 min ago, by Tony The Lion
I never even understood the point of finalizers
 
I'm trying to come up with something in C# that does exactly RAII.
 
10:42 PM
why was this starred?
14
 
it does seem simple but why isn't it simple in reality
 
@RMartinhoFernandes Ah, I think I wanted usual but also best practices.
 
@TonyTheLion because I never understood it either.
 
@SethCarnegie Hmm, seeing the number of dependencies that need to be installed, you should definitely link to the prebuilt version when you make the Q/A.
 
10:42 PM
I'm thinking something in the form of delegates and some arcane magic.
 
@Mysticial do I even need to make the Q/A?
 
Thankfully there's try(...) in Java 7.
 
@TonyTheLion Look, it's a message that tracks the count of idiots in the room.
 
@SethCarnegie Imagine two objects that call each other in their finalizer methods. Do you see a problem?
 
but GC doesn't run in a deterministic fashion, but what makes the running of a finalizer so non deterministic? Doesn't it get invoked each time the GC cleans up an object?
 
10:43 PM
@Mysticial seems like rubenvb's prebuilt versions obviate the need for one
 
@SethCarnegie It could be very useful to others. And could get you a fair amount of rep badges?
 
WTF is wrong you you people?
 
@TonyTheLion And "each time the GC cleans up an object" is when exactly?
 
@TonyTheLion The time when the finalizer is run cannot be inferred from looking at the source alone.
 
@Mysticial ok I guess
 
10:44 PM
@RMartinhoFernandes I don't know, when it runs?
 
@Mysticial do you have time to test it? I tested it on another of my non-dev machines and it worked
 
@TonyTheLion Just because we can
:)
 
@TonyTheLion But that's "possibly, sometime in the future". Not deterministic at all.
 
@TonyTheLion No! It's entirely possible that an object is garbage collected without the finalizer being run in Java if you look at the spec. Don't rely on finalizers. Finalizers are broken.
 
10:45 PM
but what if the GC never runs?
 
@SethCarnegie Link me the pre-built one and I'll run it through some test programs.
 
I wonder if it will show in its own frame :s
 
@FredOverflow And may cause memory leaks!
 
Not really up to date on the Java spec, but in C#, finalizers will run unless the application is closing down, and they're taking too long
 
That's probably more feasibly be me trying to build it myself.
 
10:45 PM
So they will run, or they won't then. Okay.
 
yea so essentially like the threads on the running queue in windows, they're on the queue, but you're never guaranteed they will run
 
once the process tries to exit, the finalizer thread will go through everything that should be finalized, but if it takes too long, it just gets killed
 
Threads must be guaranteed to run.
 
@Mysticial no, I mean do you have time to follow the instructions to build clang
 
10:46 PM
so even if your process shuts down normally (not a crash), the finalizers might just get skipped
 
Unfair scheduling system would starve the system.
 
I don't have Python properly installed, nor do I have Perl. I just installed MinGW and I don't know how to use it yet... soooo....
 
@CatPlusPlus not if you read the Windows Internals book
 
@jalf possible isn't it.
 
@jalf That's why you should really stick to Dispose and using.
 
10:46 PM
@jalf Some smart guys once studied code found in real world C# finalizers and noticed "90% of all finalizers out there are broken. It's really hard to get them right."
 
@FredOverflow so GC relies on the fact that the operating system will reclaim used memory when the process ends, correct?
 
@TonyTheLion From what year? :P
 
@SethCarnegie I have no idea. Why do you think this matters?
 
@CatPlusPlus the last one, well, the one that covers Vista
 
I've learnt that the whole probably something wrong with your code instead of the compiler doesn't really apply for VBA: support.microsoft.com/kb/823604
 
10:47 PM
@RMartinhoFernandes you can use magical lambdas to hide usings.... and template them.
 
@Hoxieboy What is that image ? Are you in some graphics class ?
 
@CatPlusPlus What if I pull the plug before it gets scheduled?
 
@FredOverflow oh actually nvm, was thinking of something else
 
@TonyTheLion Schrödinger with a vengeance. Thread guarantees no longer hold, when you are reading a certain book. Woah, is that cat dead yet?
 
@SethCarnegie Not running a finalizer doesn't mean that the associated memory isn't released. Implementations may rely on the system, but I'm sure the specs guarantee it.
 
10:48 PM
@RMartinhoFernandes You're interfering with the laws of nature.
 
@LucDanton yeah, I was thinking that but that's not the case
 
@Mahesh Looks like someone is dabbling with a physics engine :)
 
I mean, I was thinking it was the case but it's not
 
too bad .NET value types don't have destructors.
 
@LucDanton I don't get what you're trying to say
 
10:48 PM
@Xaade That would require copy constructors too to get it right. IOW, the whole C++ value semantics model.
 
but a GC has to run in a thread, and if it's not guaranteed to run, then wtf?
 
So, let's say I have a launchMissile() function in C++. Inside, I set up a Mutex before fueling, aiming and igniting the missile. If an exception happens in fuel(), aim() or ignite(), Mutex's destructor is called immediately and other threads can resume.
 
@RMartinhoFernandes Value types die at the end of the scope don't they?
 
GC doesn't have to run in a thread.
 
C# structs don't have copy constructors? That severly limits their use, doesn't it?
 
10:49 PM
@TonyTheLion I was saying that if the OS didn't reclaim memory then the memory doesn't get deallocated because the finalisers don't get run, but really the GC deallocates all memory but doesn't run the finalisers
 
I can't quite believe a GC for .NET or Java runs in kernel mode
 
@FredOverflow My computer graphics class was a night mare for me. OpenGL assignments were tough :(
 
unless its a DPC
 
Well, separate thread. You always have a thread.
 
@TonyTheLion release the memory without running the finalizers first?
 
10:49 PM
GC doesn't run in kernel mode.
 
If I have that same function in, say, Java, I need a finally block to unlock the Mutex after an exception is thrown. Right?
 
@FredOverflow That's what I thought when I thought of generics.
 
@TonyTheLion Normally, the Garbage Collector only runs when a request for memory cannot be satisfied.
 
@RMartinhoFernandes SHIITAKI MUSHROOMS
 
10:49 PM
I finally found the one I liked: "Destruction is Resource Relinquishment"
 
{
    var x = new SomeValueType();
     // only cleaned up here if some optimization kicks in
}
 
@TonyTheLion I wanted to point out that finalizers not being guaranteed to be run doesn't prevent the guarantee that all memory will be released at the end of program. I'm not sure that point was entirely relevant here though, the discussions is sort of hard to follow.
 
@FredOverflow ah ok, now it's starting to make sense
 
Installing Perl...
 
@Xaade Shiitake, not shitaki
 
10:50 PM
@FredOverflow erm AFAICT they just have member-wise defaulted copy construction emitted by the runtime.
 
@FredOverflow yep. C# structs are basically pointless
 
pointers are pointless
 
@Maxpm Exactly. So the caller has to remember to wrap it like that, in order to ensure deterministic cleanup
 
oh, but we knew that already :P
 
Functions are pointfree.
 
10:50 PM
@FredOverflow Yes, their use is severely limited.
 
@MooingDuck KWID: Know When It Dies ?
 
@jalf immutable data....
 
@TonyTheLion null pointers are :)
 
if (heap + x > boundary)
    run garbage collector
    if (heap + x > boundary)
        throw out of memory exception
result = heap
heap += x
return result
 
10:51 PM
Is delete nullptr; UB?
 
^ very simplified
 
You'll notice that on SO, people using C# structs will quickly gather comments regarding it.
 
@jalf Gotcha. Thanks.
 
Your Object Will Die
 
@daknøk no?
 
10:51 PM
@daknøk no, you can safely delete a null pointer
 
@daknøk It doesn't compile.
 
@RMartinhoFernandes shouldn't it convert?
 
@CatPlusPlus TOAD them objects always die.
 
@MooingDuck Irrelevant.
 
@MooingDuck I'm surprised it hasn't been mentioned (I may have missed it) but a somewhat popular alternative to 'RAII' is 'scope-based resource management', or SBRM. Easy to remember thanks to short-range ballistic missiles, right?
7
 
10:52 PM
@sehe CD: Certain Death
 
@MooingDuck To what?
 
@RMartinhoFernandes +1 and very easy to get wrong. In inexperienced hands, C# structs are a recipe for disastrous bugs. And a boatload of unwieldy SO questions
 
@LucDanton That sounds like it actually describes what's going on.
 
So GC would be ICBM?
 
if (false)
  run garbage collector
^~~ how java does it
 
10:52 PM
if (garbage) make more garbage;
 
installing cmake...
 
How Fry does it.
 
@daknøk while (true) if (false) runGC();
 
@CatPlusPlus no, if (garbage || !garbage) make more garbage;
 
@CatPlusPlus Inconsistent Cleanup By Mother?
 
10:53 PM
@RMartinhoFernandes operator delete takes a void* doesn't it? I didn't think about the destruction though, you're right.
 
What's the point of function pointers?
 
The IC was good, I thought. The BM part could probably use a bit more work
 
@Maxpm a function
 
@MooingDuck delete expr; is a delete expression, not a call to operator delete.
 
@Maxpm they... point to functions?
 
10:54 PM
I C a ballistic missile.
 
@MooingDuck What Luc said.
 
Xeo
@RMartinhoFernandes As Bjarne said it, "it wasn't his best day for naming things"
 
You can't use void* in a delete expression as void is an incomplete type. You need a complete type to run a destructor (which is the first thing that happens in a delete expression).
 
@MooingDuck What Robot said.
 
My SO chat is like... buffering everything. It looks like silence, then you all post 15 messages, then silence, then 15 messages...
 
10:54 PM
@Maxpm It's C's way of treating functions as values.
 
Woa, lots of peeps in here.
 
It's so noisy today.
 
Xeo
@LucDanton C++11 outright banned delete (void*)nullptr; :(
C++03 was just undefined behaviour if the pointer was non-null.
 
What is there to be sad about?
 
30
Q: What is the point of function pointers?

grammI have trouble seing the utility of the function pointers. I guess it may be useful in some cases (they exist, after all), but I can't think of a case where it's better or unavoidable to use a function pointer. Could you give some example of good use of function pointers (in C or C++)? Many tha...

 
10:56 PM
@Xeo Why the heck would you want that not banned?
 
Xeo
19
Q: Is it undefined behaviour to delete a null void* pointer?

XeoI know that deleteing a null pointer is a no-op: In either alternative, if the value of the operand of delete is the null pointer the operation has no effect. (C++ Standard 5.3.5 [expr.delete] p2) And also that deleting a void* pointer is undefined behaviour because the destructor can't ...

 
Fuck, I don't have winrar installed on my server... Can't extract the damn .tar.gz files...
 
Lol, WinRAR.
 
Ok, random internet disconnection XP
lets try this again
 
@LucDanton No, the first thing that happens in a delete expression is a check for the null pointer ;-)
 
10:56 PM
maths problems :P
 
@Xeo That doesn't really show a use case.
 
how can you delete a void* anyway
 
Xeo
@Hoxieboy Oh, math? Lemme show you what our docent tought us math with...
 
@Hoxieboy Is it a meteor shower over a hill?
 
@Xaade You can't.
 
10:57 PM
no type information, no deallocation
 
I'm extracting them via my main machine over the network...
 
@Xeo That sentence is broken.
 
Xeo
 
Can't do RAII in C#..... still stuck on figuring out a trick.
 
@FredOverflow Which reminds me that everytime I write a deleter for a smart pointer I get irremediably confused as to whether I should write a null check or not. I don't understand why I have trouble remembering I don't have to.
 
Xeo
10:57 PM
@RMartinhoFernandes Indeed.
 
But at the same time deleting nullptr is no-op.
 
@FredOverflow rofl close, the green is the trail made by a bomb moving through the air, and the red was supposed to be an explosion made by the bomb
 
@Xaade You have to stick with using.
 
it didn't mesh too well :(
 
Okay, sleep. Bye.
 
10:58 PM
@RMartinhoFernandes I'm ok with disguising using.
 
Xeo
(That picture is on bounds testing and boolean logic)
 
I can see the utility of function pointers in C, but not C++. Why have an extra language feature (with its syntactic complexities) when functors can do the same thing? Was it just for backwards compatibility with C?
 
Functors are awful and heavy.
 
I'm going to try to fix teh errorz
 
@Maxpm It's inherited.
 
10:58 PM
@LucDanton You normally need to check yourself if your provide a useful overload for operator delete.
 
Xeo
@Maxpm It's called magic, wait a second.
 
@CatPlusPlus Lol, bad time for sarcasm.
@FredOverflow Oh right, could be the source of the confusion.
 
@LucDanton What. They are!
Lambdas are better!
 
And C++ functors have a stupid name. (I see a pattern here)
 
@RMartinhoFernandes Dynamically create an object containing all variables declared on the stack, and then il.emit a using on the object before operating on internal code.
 
Xeo
10:59 PM
template<class T>
void do_some_cool_stuff(){ /*...*/ }

typedef void (*fptr)();
fptr f1 = do_some_cool_stuff<int>;
fptr f2 = do_some_cool_stuff<bool>;
 
@FredOverflow I think there's also the issue that std::shared_ptr can validly hold 0 and not be empty or something. It's madness.
 
@Maxpm Mainly for backwards compatibility, yeah, but also because function pointers of the same type can point to different functions (so you can have a fixed type for a callback function, for example), whereas functors have a unique type
 
@RMartinhoFernandes What are they called in other langs?
 
@Hoxieboy What's the strange "error" in the lower left corner of the picture? Did the bomb decide to turn around? :)
 

« first day (495 days earlier)      last day (4452 days later) »