« first day (287 days earlier)      last day (4660 days later) » 

11:08 AM
hai
 
there's a question on Programmers.SE about D
and I realized how awesome "DeadMG++" really is
after I eat lunch, I'm going to seriously crack on with it
 
heheh cool :)
u still at uni?
 
yes just got back
 
you have school in July?
 
resits
 
11:19 AM
you think you'll have passed them now?
how do I generate a pseudo random number using rand() in a certain range?
 
rand() % (end - begin) + begin
(With begin being inclusive and end being exclusive.)
For example, if you want pseudo-random numbers between 50 and 59, you would write rand() % 10 + 50, because there are 10 different numbers, and they start at 50.
 
@TonyTheTiger haven't taken them yet
 
@DeadMG oh I thought that's why you went there, guess I was wrong
@FredOverflow so what if it had be within the size() of an vector?
 
@TonyTheTiger I've come here to do the taking
@TonyTheTiger then rand % vector.size() should do just fine
 
@TonyTheTiger You really don't like solving problems yourself, do you? ;-)
 
11:27 AM
@FredOverflow i have seen your formula a lot, but doesn't this one do the same job: rand() % min + max
 
@FredOverflow oh I do, but just not today
@DeadMG oh i see
 
@Peacelyk How would rand() % 50 + 59 yield numbers between 50 and 59?
 
oh, never mind :)
just that i've seen another formula that seemed a little easier at first
 
It simply is rand() % how_many_numbers + first_number.
no magic
Note that rand() tends to be a lousy pseudo-random number generator, but that's a different topic.
@TonyTheTiger Why are you accessing a random element from a vector? Implementing quicksort?
 
@FredOverflow no actually, just have to pick a random item from the vector, to do something with
 
11:34 AM
Okay, but why? What's the bigger picture?
 
@FredOverflow well, this vector of "Animals" and I have to write a procedure where 1 animal interacts in certain ways with 4 other animals at random from the environment. Env is represented by a vector
and the excercise demands I use rand() to get a number to act as index into the vector
 
shouldn't it leave you to implement random however you want?
 
well, that's not what it says
so I guess not, this time
 
@TonyTheTiger "1 animal interacts in certain ways with 4 other animals"? LOL
 
lol yea, I wanted to keep my description short
 
11:41 AM
hi
 
How do you make sure the 5 random numbers are distinct?
 
@FredOverflow it doesn't say anything about them being distinct
I check the properties of the animal and see what interactions are possible
 
So it's okay if an animal interacts with itself 4 times?
 
and yes I know, there's flaws
that's tough shit, I guess
 
11:43 AM
o/
 
hi guys
 
sbi
@FredOverflow You can always carefully pick those random numbers to be distinct.
 
I know :)
 
can you do that with rand()?
 
sbi
@FredOverflow I know you know.
 
11:46 AM
lol, but I don't know
 
sbi
@FredOverflow And I know you know I know you know!
 
@TonyTheTiger rand() cannot magically do it, but you can if you put your mind to it.
 
@FredOverflow hmmm
 
Come on! The least you could do is store the numbers that you have already picked in a vector or something and then reject them should they occur again.
But there are more efficient solutions.
 
I'm not actually even sure I really get how the rand() % something works to get a range
 
sbi
11:54 AM
@FredOverflow <considers_a_set/> :)
 
@sbi you're not giving me a subtle hint are you? lol
 
sbi
@TonyTheTiger No, I'm in a mocking mood today. Just ignore me to keep sane. (And suffer the severe consequences!)
 
0
A: Does clearing a vector affect its capacity?

FredOverflowTo clear a vector and consume as little capacity as possible, use the swap trick: std::vector<T>().swap(foo); This creates an empty vector, swaps its internals with foo, and then destroys the temporary vector, getting rid of the elements that once belonged to foo and leaving foo as if it...

@TonyTheTiger Do you understand the % operator?
for (int i = 0; i < 100; ++i) std::cout << (i % 7) << ' ';
What will this program print?
 
sbi
@FredOverflow Why are you posting this here?
 
@FredOverflow it just give me the remains after a division,
 
11:56 AM
@sbi Because I think it is the only correct answer so far, and I want to discuss that.
@TonyTheTiger So what are the possible results of some_unknown_number % 7?
 
@FredOverflow all remainders of having divided i by 7
 
sbi
@FredOverflow SpaceC0wb0y is also right.
 
@TonyTheTiger And what remainders are those? Can you enumerate them here?
@sbi I don't see an answer by SpaceC0wb0y...?
 
@FredOverflow no (perhaps i'm being dense here)
 
0 1 2 3 4 5 6
Those are the possible results.
 
sbi
11:59 AM
@FredOverflow Oh, he calls himself by his real(?) name now, Björn Pollex. (I only looked at the avatar.)
 
So blah % 7 means "give me any number between 0 and 6".
 
@sbi he changed his name
 
@sbi But his answer is not particularly helpful, is it? :)
 
sbi
3 mins ago, by FredOverflow
@sbi Because I think it is the only correct answer so far, and I want to discuss that.
That says nothing of helpfulness.
 
awwww fuck
 
12:00 PM
Damn your pedantism :)
 
correct would be helpful too no?
 
I went to all the effort of making a blog post yesterday when I spent hours and shit on the train
 
(Is that even a word?)
 
sbi
@FredOverflow This is the C++ room, remember? Picking nits is what we do for a living.
2
 
and then I only posted it as a draft by accident and it didn't go up anyway
 
12:01 PM
And now the text is gone?
 
sbi
@FredOverflow I think the word is pedantry.
 
ohhhh damn
 
sbi
@DeadMG You made a blog post while shitting on the train?
2
 
it's a skill
 
hahahahah
that cracked me up @sbi
 
sbi
12:02 PM
@TonyTheTiger Yeah, me, too. @Dead: Now is this a typo or are you a fecalist?
 
no, it's English slang that effectively doesn't mean anything
 
lol
@DeadMG so, you're spewing out a string words that essentially mean nothing?
 
sbi
@DeadMG Oh c'mon! You cant wiggle out of every situation where you made yourself a fool in your own language by pulling the slang card.
 
@sbi You forgot to put "pedantry" in quotes ;-)
 
@sbi but this "and shit..." phrase is something I use too in that way
 
sbi
12:05 PM
@TonyTheTiger Yeah, and in order to give it a meaning, he now builds a parser for it. A parallel one, even.
 
@sbi Yeah. It's like excusing your lousy C++ code with "I'm a Java programmer!"
 
so I think it's a valid way of saying something
@sbi lol hahah
 
sbi
@FredOverflow No, I didn't.
 
@FredOverflow but that excuse is valid! Java is an excuse for most anything! :P
 
@sbi But it is slang. Specifically, it refers to unspecified variations on something previously mentioned.
 
12:06 PM
"My life sucks, I blame Java" - see it works!
 
@TonyTheTiger It does mean something but well, it's slang, so the definition isn't exactly codified
 
sbi
@TonyTheTiger So?
 
@sbi "I think the word is pedantry." does not make any sense without the quotes around "pedantry".
 
@DeadMG I know, I was just joking
@sbi so it means it's not something @DeadMG just made up
@FredOverflow you're a C++ programmer by any chance??
 
@TonyTheTiger I'm not a <insert any language here> programmer. I'm just a programmer.
 
12:08 PM
@FredOverflow oh....
you like it at a higher level of abstraction
language is just a detail
lol
 
sbi
@FredOverflow Doch, it does, only in a different way than the one you thought of. (And, anyway, since you're now trying to nitpick on me for revenge: You did not say the sentence makes no sense, you said I forgot those quotes. That's not necessarily two 100% congruent statements.)
 
hm, I see
 
nitpick wars!!!
 
sbi
@TonyTheTiger No, he didn't. Others have shit in trains, too. What do you think those lavatories are in there for?
 
Is it really "have shit"? Sounds strange.
Kann man Milch im Wasserkocher kochen?
 
12:10 PM
@sbi /me looks confused
 
@FredOverflow That's right- it should be "shat".
 
@FredOverflow hmmm vielleicht
 
sbi
@FredOverflow To be frank, I'm not all that certain about the exact grammar of the verb "shit".
 
@FredOverflow take a shit...
"I'm having a shit" is also valid I think
 
sbi
@FredOverflow It will burn at the metal that heats the water.
 
12:12 PM
yes
 
yes what?
 
you can have "shit" as an object, and you can "shit" as a verb, and an adjective, but "shat" is the past tense
it's not as flexible as "fuck", which is basically insertable absolutely anywhere and in any context
 
absofuckinglutely
fuck has to be the most flexible word in the English language
I mean you can really fuck anything... it will always make sense! :P
 
lol
yes, it's truly impressive
 
fucking impressive
lol
 
12:15 PM
congratulations, you took the cheapest, most obvious joke ever
 
hahah
 
sbi
@DeadMG Yeah, that was so fucking obvious. hard to make it cheaper still.
 
I guess this is true
 
sbi
@TonyTheTiger Did you not dare to inline this? :)
It's not like you had a reputation to lose here.
 
@sbi it wouldn't inline it
 
sbi
12:25 PM
@TonyTheTiger That's because you didn't post the link to the actual image.
 
I know i don't have anything to loose, all I can lose, I've already lost anyways
happy now?
lol
 
sbi
@TonyTheTiger I suppose this is on a rally pro homosexual marriage? Otherwise it doesn't make much sense to me.
 
@sbi it was merely funny... that's all, I don't where it is, or anything
 
sbi
@TonyTheTiger I was happy before, but, yeah, at least you didn't dimmish that.
 
@sbi oh ok, good we clarified that :)
 
sbi
12:27 PM
@TonyTheTiger You don't know where you got this from?
 
@sbi oh I know where I got it from... reddit
reddit/r/funny
lol
 
sbi
@TonyTheTiger Well, the girl's shirt could say "Legalize Gay", which would be funny on a girl's shirt, but it would fit my hypothesis, so for the moment I'm going with that theory.
 
@sbi not a bad theory, hadn't really examined the picture that thorougly
 
sbi
@TonyTheTiger Really, what kind of programmer are you? You see a riddle and forget to try to understand its mysteries?
Well, I guess that's because to you the picture looked like this:
 
@sbi Pretty sure that it's from the aftermath of "Proposition Hate" in California, where gay marriage was legally banned
 
sbi
12:39 PM
 
@sbi lol, nice :)
 
sbi
@DeadMG I knew someone would manage to break into the middle of these two messages while imgur delayed the second one. Could have counted on you, actually...
 
@sbi Hey, it was totally random that I happened to look up at this exact moment
 
sbi
@DeadMG Of course. I fully understand.
 
@sbi Liar :)
I really need to work on my communication skills sometimes
I tend to be quite in-your-face and informal, even when there's no possible way that over the Internets or as a fresh acquaintance, you could know that it's not supposed to be offensive
 
12:48 PM
-__-
 
user53670
what right does her want?
 
May be gay rights?
 
sbi
@DeadMG I hope this burst wasn't caused by you thinking you had offended me with that "Liar" message. Because you hadn't.
 
1:07 PM
@sbi No, it was something completely different.
Even if it would have once, I would expect that by now you would know different :P
 
sbi
@DeadMG I always knew you're different. :b
 
@sbi Genius and C++ Expertâ„¢
 
sbi
@DeadMG No, different as in "making such stupid statements and believing we wouldn't LOL about them". :)
 
@sbi How are the two mutually exclusive? ^^
 
sbi
@DeadMG They aren't. You do make such statements and you also believe we wouldn't laugh.
 
1:11 PM
no, I meant being a genius and making stupid statements
 
sbi
1:30 PM
@DeadMG Oh, I must have misunderstood then.
 
so what's new? :D
 
2:24 PM
wow
Andrei Alexandrescu called me misinformed
 
@DeadMG where? when?
 
16
Q: What does C++ do better than D?

AntoI have recently been learning D, and am starting to get some sort of familiarity with the language. I know what it offers, I don't yet know how to use everything, and I don't know much about D idioms and so on, but I am learning. I like D. It is a nice language, being, in some sort of ways, a hu...

He said that because D builds on the memory model of C, just like C++ does, that they both offer the same level of control
and I can't quite see how that works when D doesn't have multiple inheritance, mutable, and that kind of thing
 
D has multiple subtyping, right?
 
only Java-style interfaces
they have some other stuff like mixins, but you can't inherit multiple implementations
 
2:42 PM
Hello.
 
3:00 PM
I don't care too much about implementation inheritance...
 
I've never used it and can never imagine a situation where I will
but that's not the point
the point is that he said that D offers the same level of control, but it doesn't because you can't multiply inherit
 
sbi
@DeadMG Rejoice! Most of us here will never be called anything by anyone as famous as Alexandrescu. :)
 
I honestly don't care that much
he's just another guy
and he's wrong at that
 
3:54 PM
A divine intervention, eh.
I was thinking about giving D another shot, lately.
 
after reading some of the points in that post, I wouldn't touch it with a six-foot barge pole
"D assumes that all objects can be moved by bitwise copy". Yeah, thanks D, I didn't want to, y'know, update another class on the move, or something like that.
and no logical const is a big bad
 
sbi
4:15 PM
@CatPlusPlus LOL!
 
sbi
4:32 PM
@DeadMG Yeah, we've noticed.
 
4:54 PM
I like that bitwise-copy stuff, it gets rid of a load of complexity.
 
by that, you mean "You must heap allocate everything of a non-trivial complexity".
that doesn't get rid of any complexity, it just moves it to the heap and I hope the GC is fast and collects my objects deterministically.
 
sbi
I'm never quite sure about the syntax of bind, since I never got the chance to play with it before I had to use C#, so could anyone tell me whether I messed it up here, please?
 
5:10 PM
I think it's obj first
but pretty much every compiler that has std::function also comes with lambdas
 
sbi
@DeadMG Thanks, I switched it.
@DeadMG Yeah, I had already added that.
 
@sbi Pointer to member first
Think pointer to function: you pass the pointer and then the arguments, starting with the object.
 
sbi
@LucDanton <sigh/> Can you guys try to agree? :) Yours seems to make sense, though (in fact, it's what I thought), so I'll change it back.
 
I'm correct. I use bind regularly, and I have partially reimplemented it. Or just lookup the doc yourself O_O.
 
sbi
@LucDanton Why would I want to look it up when asking you seems so much easier? :)
 
5:20 PM
I'm okay with that but complaining about inconsistent answers really takes the cake :p
 
sbi
@LucDanton See, I deliberately corrected my original "is so much easier" to "seems so much easier". :b
 
lol
 
Yes, it's bind(pointer, object)
Possibly boost::ref(object).
 
Also possibly and equivalently to ref: &object
 
5:37 PM
@DeadMG What? No, I meant more along those lines:
12
Q: Making swap faster, easier to use and exception-safe

FredOverflowI could not sleep last night and started thinking about std::swap. Here is the familiar C++98 version: template <typename T> void swap(T& a, T& b) { T c(a); a = b; b = c; } If a user-defined class Foo uses external ressources, this is inefficient. The common idiom is ...

You don't need rvalue references and move semantics with D's bitwise-copy "move".
 
actually, you do
I hope that you didn't, for example, intend to alias those classes
in fact, in my answer to your question, then I listed plenty of scenarios where it doesn't work
 
Of course it doesn't work in every scenario. It's a trade-off between simplicity (D) and total control (C++).
Given how hard it seems to be to grasp rvalue references, I would prefer simplicity.
 
sure, but there are already plenty of garbage-collected simple languages, like Java or C#
 
But they don't have "move semantics" at all. D at least hast "bitwise move semantics".
 
actually, it doesn't
D's bitwise move semantics are memcpy
it only has bitwise copy semantics
 
5:45 PM
But it behaves like a move. Either the original is somehow reset into a default state, or it is simply ignored during destruction.
(not a D expert here)
12
Q: Does D have something akin to C++0x's move semantics?

FredOverflowA problem of "value types" with external resources (like std::vector<T> or std::string) is that copying them tends to be quite expensive, and copies are created implicitly in various contexts, so this tends to be a performance concern. C++0x's answer to this problem is move semantics, which...

 
no, it's destructed regularly
have a look at the question on programmers- in the comments to Andrei Alexandrescu's answer, the D guy there basically says "You'd have to use a reference type".
 
@DeadMG But then the "copy" would be in an illegal state. I don't think you're right here.
Too bad I don't have a D book around. Pretty sure I read there that the original simply wasn't destructed anymore.
 
@FredOverflow That's exactly the problem. The "copy" would be in an illegal state.
in D, you get a "postblit" constructor where you can copy the internal state before the old is destructed
but you don't get told lvalue or rvalue or anything like that
so you can only copy the object
 
Wait, postblit isn't called at all when you move, I believe. Damn it's hard to find information on this!
 
sure
that's the problem
how can I update any pointers to the moved value?
 
5:51 PM
You can't. That's an inherent limit of D's "move" system.
 
which is why it sucks
rvalue references might not be the most comprehensible thing in every circumstance, but they're actually correct in all of them, which is a plus
 
I don't think it sucks per se, it's just a different, less complicated (and less powerful) system.
 
well, in the vast majority of cases in C++, you would never touch rvalue references
they would be called automatically
 
@DeadMG I'm still not sure we got them 100% right. They have gone through many revisions already.
And there were lots of papers. Should we do implicit moves or not? What's the state of a moved-from object? What about class invariants, do we break old code? etc.
 
sure, but that's why the Committee takes it's time
yes, rvalue references are complex
 
5:54 PM
And the C++ community has been at it for 9 years already. The first paper about rvalue references is from 2002.
 
but you, as the average C++ user, almost certainly don't have to care
sure, but a lot of that was wasted on concepts and used on other non-rvalue things
 
"wasted on concepts"? :-(
I hope concepts will eventually make it into C++...
 
so do I
but they didn't, so that time was expended and we've got nothing to show for it because concepts didn't make it
I feel that too much time was spent on them and not enough on modules, and some other stuff that deserved to make it
well, ok
if I finish "DeadMG++" then I don't care whether or not concepts make it
but you get my point
 
0
Q: Questions about postblit and move semantics

FredOverflowI have already asked a similar question a while ago, but I'm still unclear on some details. Under what circumstances is the postblit constructor called? What are the semantics of moving an object? Will it be postblitted and/or destructed? What happens if I return a local variable by value? Will...

I don't like not knowing things.
 
6:33 PM
an excusable condition
 
@DeadMG It isn't destructed according to this answer:
0
A: Questions about postblit and move semantics

jA_cOpAs far as I understand: 1) When a struct is copied, as opposed to moved or constructed. 2) The point of move semantics is that neither of the two needs to happen. The new location of the struct is initialized with a bit-wise copy of the struct, and the old location goes out of scope and becomes...

And I think he is right. Otherwise, moving in D would not work at all.
 
yes, but it's also not constructed
so you can't
do anything complex with it
check out your old question- howard hinnant posts about "member end" or something like that which is used to implement containers
where pointers to inside member objects is used
 
I think we have already established the limits of D's "move semantics" :)
 
ok
they don't have move semantics, they just have not-a-copy semantics
 
6:50 PM
@FredOverflow Alright, now that I have some time -- the safest types to memcpy around are the ones that are trivially copyable IIRC.
> Containers are generally reference types (in Phobos, they're structs rather than classes, since they don't need polymorphism, but copying them does not copy their contents, so they're still reference types)
D is insane.
 
yes
that I have observed
 
It's not that far from a language that I'd appreciate :( Just the forced polymorphism/reference types/forced dynamic allocation is simply the plague of OOP.
Fuck the slicing 'problem'; there is no problem.
 
agreed
why does everyone hate value types?
and limit them
values are just fine
 
I've made perfect build configuration system.
 
7:10 PM
@LucDanton So what are the semantics of copying Phobos structs? Reference counting?
 
Well I can only assume it is.
That would require a deterministic destructor to decrement the count though.
 
strange
 
If it's relying on the GC instead there is no counting at all then.
 
@LucDanton Well, structs have deterministic destructors, don't they?
 
Not familiar enough with D here.
 
7:13 PM
How is tool support for D? Is there a nice IDE with auto completion and refactoring mechanics available?
 
Apparently, the toolchain support is really quite immature
I've heard that the GC has a sucky implementation
 
:-(
GC is one of those things that sounds quite easy in principle, but which turns out to be quite hard to implement correctly and efficiently.
 
How come there's no up-to-date benchmark for differing GC implementations? Too different in their purposes?
E.g. a GC for a JVM implementation would have different specs/tricks to use than another one?
 
depends a lot on the language semantics
for example, in C++ you could magic up pointers out of random memory buffers
the C# GC has to support memory pinning for use with native code
the JVM GC doesn't
 
good points
 
7:16 PM
as far as I know
also note that C# has a lot more support for closures and shit like that than Java
which may also complicate the implementation
 
For instance I have no idea where the Lua collector ranks. Or what Luajit does on that front.
 
I know for sure that Lua uses mark and sweep
how it ranks for speed, I don't know
but Lua as a language is so dog slow that it doesn't really matter either way
and a pretty shitty language, to boot
 
I'm still curious regarding Luajit.
 
don't know, but they probably do the same as normal Lua, just compiled
remember that Lua only has a very few data types and you can't re-define them
so from a type perspective, Lua is extremely simple
and stores it's types at run-time so the collector can just query it
 
I don't think any of those affect the GC.
 
7:21 PM
it's a big deal to the GC, because it doesn't have to look for native pointers
 
Even a GC for a static languages has to make assumptions or otherwise use tricks to check the types at runtime.
@DeadMG Untrue regarding userdata and lightuserdata
 
light user data aren't collected, they're values (pointers)
strings themselves are interned and you could probably get away with never collecting them
and you know that userdata never contain any pointers to Lua values
tables and functions are the only types that could
foreach(lua variable on the stack) if (type(variable) == 'table' or type(variable) == 'function`)) then mark as active, look inside and recurse on them. foreach(lua variable in existence) remove all which aren't marked
and because those types are fixed, you can hard-code the "look inside" code
 
That's not extremely Lua-specific though.
Of language implementations with a GC, which is the majority: the memory-safe ones or the unsafe ones?
 
the "look inside" code will be
what do you mean by memory safety?
 
A memory-safe language won't let you poke 'inside' the object/memory model.
 
7:28 PM
so "you can't do random things with random blocks of memory" kind of thing
 
Your algorithm would work just as well for OCaml from what I know of it.
@DeadMG No idea if there's a formal definition but that's the meaning I have gathered myself.
 
well
implementing a collector and a language that can cope with memory-unsafety is decidedly non-trivial
node-based containers aren't that difficult like linked lists, they can be memory-safe but contiguous memory containers like vector can be harder
 
Reading on Boehm GC baffled me at first -- "oh yeah sometimes an integer can be mistaken for a pointer".
But then I realized this is mostly harmless.
 
yes
the probability of an integer being the correct address and such is quite remote
and it will probably be gone or changed by the next cycle
 
Memory-unsafety loses the cool tricks like compacting but still it's workable.
What is GC-capable and memory-unsafe and is not C++? I know C# has hooks but I don't know how it compares.
C++/CLI counts I suppose:
 
7:33 PM
C# can do it
they have an unsafe keyword and in unsafe code, you're memory-unsafe and can do whatever you want
 
Does the GC do tricks for the rest of the code still?
Or does the keyword 'contaminates' the process?
 
I actually don't know
they have some GC commands, maybe that has to do with it
but I know for sure that the C# GC is a compacting GC
so it's perfectly legit for the GC to move objects if you don't explicitly pin them
 
7:49 PM
 
lol
 
> TERRA INCOGNITA: programmers eat each other here
 

« first day (287 days earlier)      last day (4660 days later) »