« first day (699 days earlier)      last day (4243 days later) » 

11:07 AM
> The Galápagos National Park Service systematically culls feral predators and competitors. Goat eradication on islands, including Pinta, was achieved by the technique of using "Judas" goats with radio location collars to find the herds. Marksmen then shot all the goats except the Judas, and then returned weeks later to find the "Judas" and shoot the herd to which it had relocated. This process was repeated until only the "Judas" goat remained, which was then killed.
I love it, a "Judas" goat
 
that goat must feel like the most depressed goat ever
 
"Whenever I arrive, all my friends die. Oh well. Time to find some new friends!"
 
guys
 
@Cicada Hello.
 
11:10 AM
Hello there!
Is "to sell sand in the desert" some kind of English idiom?
 
@Cicada Probably. Haven't heard it though.
 
I'm being described by some people as a "sand merchant in the desert" and "ice cream seller in groenland". I'm not sure how to interpret this ಠ_ಠ
 
Yes, it's like selling Ice to the Eskimo.
 
Also my C++ teacher does not know the difference between int const foo(); and int foo() const;. Or have I ranted about this already.
4
 
@Cicada I think it means you're really good at selling stuff.
 
11:13 AM
@TheForestAndtheTrees Yes exactly, how would you interpret it?
@Insilico Or being useless? :D
 
I dunno, it depends on whether I'm actually succeeding at selling ice or not, it's either an insult to indicate I'm not doing very well or a compliment to say I am.
 
@Cicada Girl!
 
@sehe BEAR!
 
Ooohh, everybody Duck!
 
@TheForestAndtheTrees Hmmm, this mystery is getting thicker then.
 
11:14 AM
Hi back
 
@sehe Also what was that ping you sent me?
 
@Cicada You'd have to have been there. Remnants on the starboard
 
Did everyone change gravatar & nickname to DeadMG?
 
19 hours ago, by Cat Plus Plus
Let's all become DeadMG for a month.
@Cicada Basically. Yes. Kafka meets Thomas Crown Affair.
 
@sehe What.
 
11:16 AM
It was a new high-point in the history of lounge insanity
 
Can you do Base to derived with a static_cast?
 
@Cicada It was bit surreal
 
@sehe Which is a real achievement.
 
@TonyTheLion Nope. Unless there is a conversion operator/constructor
@Insilico I thought you'd appreciate that. Which is the reason I plinked :)
 
@Cicada The pity is I wasn't here to see it
 
11:17 AM
That's irony
 
Wasn't it supposed to last for a month anyway? I'm confus
 
I don't know why that always has me confused
 
You can do a Base* to Derived* via static_cast.
 
right
so what the fuckles is a full CV, as opposed to my existing CV?
 
11:19 AM
"C++" course in 10 mins. Probably gonna learn how to dynamically allocate objets with malloc(sizeof(Class)) or something. See you!
 
@Insilico Really? That's not really safe, is it? Or does the compiler complain when it's not safe?
 
@DeadMG you have a full CV.
 
@TonyTheLion Not according to at least two recruiters who emailed me to ask for one, as opposed to my existing one.
 
Just ignore that recruiter, email them tell them you've attached an up to date copy of your current CV
 
@DeadMG It's the one that you send in response to a request for "the full CV".
 
11:20 AM
@Cicada C++ for do-it-yourselvers.
 
@sehe It's definitely allowed, as long as Derived is actually a subclass of Base. Now, of course if your Base pointer doesn't actually point to a Derived and you attempt to use it as a Derived then you're on your own. (i.e. UB)
 
@sehe It can be safe.
but it's one of those, "You'd better not be shitting me or UB" kind of things.
 
@DeadMG I know that. But the general case is a bit more resistant
 
@sehe Ok that didn't make sense. (What I said.)
 
@sehe Yeah. I'm not saying it's a good idea. I'm saying that it is legal and can be well-defined behaviour- as long as you're damn sure it's really a Derived*.
also, there are some cases which cannot be static_cast- namely, when virtual inheritance is involved
 
11:22 AM
@StackedCrooked define "safe". You probably meant: the implementation is well-defined and will be correct regardless of type hierarchy. But you are on your own making sure that the specified conversion makes sense for the runtime values
@DeadMG That was my question:
> Or does the compiler complain when it's not safe?
 
@sehe Indeed.
 
@sehe No, no, no.
 
@sehe The compiler will complain if Derived is not a subclass of Base.
 
the compiler does not complain at all when it's not safe - only if it's impossible.
 
Otherwise it assumes you're not completely crazy.
 
11:24 AM
that is, if Derived is not a derived class of Base, or there's virtual inheritance going on.
you have to validate the safety yourself.
 
@DeadMG Ok. That answers my question
 
One use that comes to mind is when implementing circular doubly-linked lists. You would have a NodeBase that has next and previous pointers to other NodeBases.
Then you would have a Node that derives from NodeBase that actually holds the data
 
@Insilico That's the part that mildly surprised me. I had 'static_cast' archived under 'S' of 'Sane' in that it wasn't one of those 'compiler-shut-up-I-know-what-I'm-doing-casts' (like c-style or reinterpret_cast e.g.). Turn out I need to nuance it more.
 
Or static polymorphism. E.g: static_cast<CRTP &>(*this).foo();
 
@Insilico I can think of usecases. That is a simple, good one
 
11:26 AM
@sehe All casts are "shut-up-I-know-what-I'm-doing" things. It's just that unlike C-style casts, the C++ casts aren't "all-purpose".
 
@Insilico dynamic_cast?
 
@sehe I would probably even classify dynamic_cast as a "shut-up-I-know-what-I'm-doing" tool. It just happens to have runtime checks.
 
@sehe It kind of is. It can't make casts that violate strict aliasing, for example, and you'll get a compiler error if there's no sane possible conversion.
 
@sehe I have shot me in the foot with static cast to the wrong type. It leads to very confusing debug sessions.
 
Generally speaking you want to minimize the use of casts, C++ or C-style.
 
11:29 AM
@StackedCrooked Izzama point
 
@sehe Ah, I once visited Izzama point.
 
@Insilico I static_cast on a fair number of occasions.
 
always best to do a dynamic cast and check the result in debug mode.#
 
@LucDanton Of course. I didn't say "don't use them".
 
0
Q: Is this simple but useful pattern too simple to be a real pattern?

Gob00stOverwrite a derived function behaviour while still calling the same function of it's parent, see C::foo() for example.It still have the behaviour of A::foo but extended it. Is it too simple to be a pattern ? class A { public: virtual ~A() {} virtual void foo(){ MSG("A::foo");} }; class ...

what the fuck is wrong with people?
 
11:31 AM
Even then if I find myself using a bunch of static_casts, I would probably check that I'm using the correct data types in the first place.
 
"Hey guise, I used a language feature! Now I'm a pattern guru! Kindly tell me which exact pattern I am now the master of"
 
Yeah, but I don't want to minimize the number of static_cast. That doesn't make much sense: what's an alternative?
 
@StackedCrooked 61a2391db4b758f75d7e81ba96cdec224226cfaa
 
@DeadMG I sometimes use a downcast function which results in dynamic_cast or static_cast depending on a compiler switch.
 
@LucDanton Good design?
 
11:33 AM
@Insilico Zing.
 
The only place where I find myself using a bunch of casts are the parts of C++ code that talk to C APIs (e.g. the Windows API).
 
static_cast can be used to express "construct T from U". What's a better design than not constructing instances?
 
@DeadMG Can't you define a "Tony's Pattern" as well
 
Hmm. You can use static_cast here (not in his original question with slicing and all, but casting of any kind is no help there). You just shouldn't. — BoBTFish 10 mins ago
 
@DeadMG What's wrong with that question? Oh, I see your reply now.
 
11:33 AM
I don't get why casting is no use
 
@StackedCrooked i don't understand the rationale for that. you use static_cast for a downcast when you know the types involved. i fail to see how you can know that overall for all types so that it's appropriate to use a compilation switch
 
@LucDanton T my_t_object(u);?
 
It predates patterns. And it is just functional composition (meets class-responsibility). IOW, you wouldn't call a loop a pattern... — sehe 1 min ago
 
static_cast can be used for downcasting.
 
the most useful cast is implicit_cast. it is unfortunately not supported by C++.
 
11:34 AM
Implicit is bad.
 
So you truly think that T t(u); return t; is better than return static_cast<T>(u);?
 
implicit_cast makes the implicit explicit
 
@LucDanton return T(u); is way better than return static_cast<T>(u);.
 
@Insilico That uses the semantics of C-style cast and can bite you in the ass.
 
Yep, (T)u and T(u) is the same thing
 
11:35 AM
@ManofOneWay Tony's Pattern: "porn"
 
Welcome to C++
 
@sehe it could be a (limited) implementation of the decorator pattern. On the other hand, when using the NVI-idiom then you get the template method pattern. I have often wondered which of the two is superior.
 
You suck. (he said in a friendly manner.)
 
Fuck C and its C-style casts.
 
@StackedCrooked Template methods for the win
 
11:36 AM
@LucDanton I think that, intuitively, it should be.
 
Linking to pattern questions should be bananable offence.
 
@Cicada you're attending c++ classes?
 
@DeadMG I'm not comfortable with the idea, especially considering I do plenty of return std::move(foo);/return std::forward<Foo>(foo);. What's so special about static_cast that I have to use the other way?
 
I still think you should minimize the use of all casts. That doesn't conflict with always using static_casts in legitimate scenarios.
 
11:39 AM
@LucDanton do you really have to. isn't that pretty automatic
 
@LucDanton I think that T(x) should imply a constructor only.
so if you had T as Derived* and x as Base*, then it should fail.
 
anyone here who knows a lot about openssl?
 
@DeadMG yes, bjarne fouled up on that one. in the interest of unity
 
I don't consider the amount of casts in my code to be a criteria of code quality.
 
@LucDanton I don't mean to say that return static_cast<T>(x) should be banned or anything like that. All I am saying is that I think that T(x) should not be a cast.
 
11:40 AM
@Insilico Let's cut to the chase: the important thing is to learn the semantics of static_cast. Once you understand what you do, there's nothing to minimize. You'll use whatever language construct will express what you want that is maintainable and error-prone. static_cast, as tools go, is very safe.
@Cheersandhth.-Alf Yes I have to. No it's not automatic.
 
parentheses are just too overloaded in c++
@LucDanton sounds like, uh, uncommon design
 
@LucDanton I don't see where the conflict is between "minimize the use of casts" and "understand static_cast and use when necessary".
I agree, one should understand and use static_casts when necessary.
 
@Cheersandhth.-Alf There would be no need for std::forward at all, as a library feature, if it was automatic. (return std::move(foo); is much more uncommon.)
 
See ? If you were to use pointers everywhere you wouldn't have to ask yourselves all these questions : you would have so many more problems to solve first.
 
@ereOn If you used pointers everywhere you would have to constantly ask yourself "Am I supposed to delete this or something?"
 
11:43 AM
Because you need to minimize the use of everything. Is "don't do i + 5 + 0 if you need i + 5" useful advice?
As advice goes it also doesn't explain how you should go about minimizing.
 
@Insilico: Yep exactly ! So you no longer have to worry about using casts or anything : you already have your hands full.
 
@LucDanton Yes. Because i + 5 + 0 is stupid. It's almost as bad as someone writing`if(x == true) { /*...*/ }`.
 
@ereOn Reminds me of a quote I heard once: "Some people, when confronted with a problem, think 'I know! I'll use regular expressions!' Now they have two problems."
 
@Neil: It's quite similar indeed.
 
@Insilico Then the advice should be "be parsimonious". Not "be parsimonious with static_cast".
 
11:45 AM
Some people, when confronted with a problem, think 'I know! I'll use pointers!' Now they-Segmentation fault
2
 
I'm not saying the advice is wrong, I'm saying it's not worth telling.
 
@Insilico Of course I "minimize" my number of static casts. I wouldn't sprinkle my code with them needlessly.
 
Actually, I made this remark because it always amaze me to see that people here argue about questions which would probably never come up were I work, because we are already facing much poorer problems.
 
@StackedCrooked And that's what I'm trying to get at. :-)
 
Use cast-free languages. :v
 
11:46 AM
@ereOn And you'd constantly be asking can I safe downcast this point here
 
@sehe: No, because you would have an instance factory borrowed from Java, and you would have to track down which code part is responsible for the problem you have been asked to solve, 5 days ago.
 
@Insilico decltype(i + 5 + 0) might be something else entirely than decltype(i + 5) and the extra operator invocations may have side-effects :) /cc @LucDanton
 
@ereOn Did you see the AbstractSingletonProxyFactoryBean?
 
@Insilico I would say maximize the higher layer abstractions and reduce "special" code.
 
@Insilico: Not that I remind.
 
AbstractSingletonProxyFactoryBeanFactorySingletonManagerController
 
thx
 
@sehe Ya but then you're not needing i + 5.
 
Apparently AbstractSingletonProxyFactoryBean is an actual class used in production programs. -__-
 
Wait...
is that for real ?!
 
11:49 AM
17
A: Is returning with `std::move` sensible in the case of multiple return statements?

XeoFor local variables, there's never the need to std::move them in the return statement, since the language actually demands that this happens automatically. §12.8 [class.copy] p32 When the criteria for elision of a copy operation are met or would be met save for the fact that the source objec...

 
@ereOn Yes.
 
Welcome to Java, where brains rot and patterns emerge.
 
@LucDanton It might be the most awkward DSL ever invented on a Friday
 
@Insilico: just... wooo....
 
@Cheersandhth.-Alf There are other things than local variables.
 
11:50 AM
So some day, some twisted mind woke up and said : "Hey ! I need an abstraction layer to wrap my bean singleton factory ?"
 
FTR a quick search for return std::move suggests it appears very rarely.
 
@ereOn I still don't know what the hell that class is supposed to do.
 
(The funny thing about that sentence, is that you can swap words at random, and it would still make sense for anyone doing Java on a regular basis)
 
@LucDanton yeah, but have you example
 
@CatPlusPlus Fungi patterns.
 
11:51 AM
@Cheersandhth.-Alf From looking at my code, a member object appears once or twice.
 
@StackedCrooked Michael Jackson zombies
 
I have one return std::move(*this); as well.
 
@LucDanton oh. isn't that dangerous, if you mean you move it out via a return value
 
"Convenient proxy factory bean superclass for proxy factory beans that create only singletons."
 
@Cheersandhth.-Alf In its current incarnation, yes (for low values of 'dangerous'). It is intended to be in an && qualified member function however.
 
11:52 AM
It's for sure convenient.
 
ok, int (*p)[size] = malloc ( size * size * sizeof( int ) ); is this valid?
in C
 
What's a "proxy factory bean" that creates only singletons?
 
@LucDanton thx. i never thought of that :-)
 
Does it even make sense to have a factory for singletons?
 
@TonyTheLion Probably. That says nothing about whether or not you should do it though.
 
11:54 AM
@Neil OP is trying to create a int** and allocated it like that
 
@TonyTheLion I don't think so. The size in int (*p)[size] has to be a constant, I think.
 
It has to.
 
@Insilico: Well, it's because its a singleton, but you can have several of them.
If one singleton is good, several can only be better.
 
I assume size isn't a declared value?
 
Xeo
Back, and the first thing I see is another random downvote...
 
11:55 AM
@ereOn A singleton for which you can make multiple instances of.
 
@Insilico And it's abstract too, don't forget.
 
@Insilico: A multipleton actually.
 
MAKES COMPLETE SENSE!
 
I love that one : A multipleton.
I'm going to use it immediately.
 
Is the Spring Framework just a huge brainfuck of its own kind?
 
11:57 AM
Every Java framework is a huge brainfuck of its own kind.
 
I need to know what the writers of AbstractSingletonProxyFactoryBean were smoking
 
@Insilico Convert [ to Factory, ] to Proxy, + to Bean
 
@Insilico ok, but it allocates a int* or int** ?
 
@ereOn That's genius.. I expect every class written in java that isn't a singleton to have Multipleton at the end of the class name.
 
@Cheersandhth.-Alf Come to think of it, the advice should apply to objects, not variables (not temporaries though). I do have an instance where I have to move a local variable, because it's an rvalue reference. @Xeo Your take on this?
 
11:57 AM
@TonyTheLion Neither- it allocates a fuckload of int.
 
@DeadMG a fuckload? Hmmm
 
@TonyTheLion It allocates a whole bunch of ints in some magical place in memory using some magical process and gives you a pointer to it.
 
@Insilico so it's not valid, for the sake of argument?
 
Don't try to get int** from a single allocation. It's somewhat possible, but just don't.
 
@Neil: Yes, absolutely. I'm actually quite sure some Java coders would think the concept is real genius.
 
Xeo
11:58 AM
@LucDanton Sorry, what is the question? I just came back.
 
@TonyTheLion I mean, just read what you've written.
malloc(fuckload * sizeof(int))
 
@Xeo Follow the trail until the link to one of your answers.
 
@ereOn You kid, but they had to invent a name for an ordinary java object (POJO)
 
thus, that's exactly what you've done- allocated a fuckload of int.
 
@Neil: Everything is better when renamed.
@Neil: You are not a Java developer : you are a Java architect.
 

« first day (699 days earlier)      last day (4243 days later) »