« first day (364 days earlier)      last day (4575 days later) » 

4:00 PM
 
cout doesn't point to a specific function
 
@FredOverflow Brillant.
 
it just points to some function
 
cout doesn't point to a function...
 
the cout implementation can return 0xDEADBEEF if it wants to and the stream is valid
 
4:01 PM
it is an ostream
oh you mean the boolean conversion
in c++11 it is explicit operator bool() anyway
 
no, I'm discussing some other context in which cout is related to a function pointer
 
in cout << somefunction it can print either 1 (when boolalpha is false) or it can print num_put<char>::truename() or whatever it was
quiz!
 
no
 
give a pointer type "T*" that is not a function pointer but points to some object, but prints 1 when given to cout like cout << ptr;
 
4:06 PM
const char* p = "1";
 
easy
 
Member pointer?
 
char* ptr = 0; ptr++; cout << (void*)ptr;
no, wait, wrong
 
@DeadMG that does not necessarily point to an object. and I think it may be UB xD
 
4:07 PM
you never said it had to point to a valid object
 
Incrementing the null pointer definitely sounds like UB to me...
 
now you get another 100 dollars if you give another way where T* is not a char pointer like that
@DeadMG it does not necessarily point to an invalid object
 
Another 100 dollars?
 
Where are my first 100 dollars? :)
 
they are at google picture search
 
4:09 PM
Do you know the answer to your own quiz?
 
@FredOverflow sure°
i will give a hint: you can use the null pointer!
if and only if I strike the "but points to an object"
 
oh, you mean like, the snippet I posted already?
 
Er, but you're not striking that are you?
 
@RMartinhoFernandes no xD
but only for the purpose of the hint
 
4:11 PM
Oh wait, I think I got it.
 
@RMartinhoFernandes sadly that is not a pointer :(
 
@RMartinhoFernandes how the value is 1?
 
holy shitnizzle
I'm implementing some Unicode-related classes
and my God, it's annoying to specify the interface like 15 billion times in a row for all three kinds of class
 
@RMartinhoFernandes shouldn't it be some address?
 
also it has somethign to do with device registers
 
4:12 PM
@MrAnubis It's converted to a bool.
@JohannesSchaublitb WTF is that?
 
@RMartinhoFernandes and which statement in the program did this?
 
@MrAnubis It's implicit.
 
How will volatile help?
 
@RMartinhoFernandes that must be the purpose of the hint not to give the full solution!
 
4:14 PM
@RMartinhoFernandes std::cout << p; ? or auto p = &f::x; ?
 
yeah
 
@MrAnubis The std::cout one.
 
except, it's rather exceptionally boring, I would put forward
so if I were you, I'd just give the full solution
it's obvious nobody knows what you have in mind
 
the quiz will give you insight into dusty c++ corners
 
@RMartinhoFernandes but why would it implicit do conversion?
 
4:15 PM
@JohannesSchaublitb Since you didn't say std::cout, here is my solution ;)
 
that insight isn't going to come from staring at your hints, it's going to come from being told what I don't know
@FredOverflow Fairly win.
 
"when given to cout like cout << ptr;"
 
cout << p;
Shall I rename p to ptr for you to accept this solution?
 
@FredOverflow wow nice solution
 
@MrAnubis Because there's no operator<< for pointers to int members of f, but there is one for bool and pointers to members are implicitly convertible to bool.
 
4:17 PM
now you get another 100 dollars if you provide a solution with only standard operators
I shall give the solution now
 
@FredOverflow That doesn't give me any interesting insights.
 
I feel rich enough already, but thanks ;)
 
@RMartinhoFernandes aah thanks
 
volatile int x, *ptr = &x; cout << ptr;
 
@RMartinhoFernandes of course not, it's an ugly cheat that wasn't meant seriously.
 
4:17 PM
muhaha
 
c++ is zig zag dancer :D
 
that should just fall back to the void* operator and point the hex address
there's no reason that it would print 1
 
you do not see the trick
 
@JohannesSchaublitb i assume your company has to control you from writing advance and nasty code :D
 
error: invalid conversion from 'int' to 'volatile int*'
Oh wait, I forgot the & operator :) Now it works.
 
4:19 PM
the ostream troll operator has something in his pitfalls case for ya
 
Why does the volatile make a difference?
 
it won't fall back to void*, because
it would have to fall back to volatile void*
and there's no such operator
 
No operator<< for pointers to volatile?
 
so the only valid conversion is bool
 
4:21 PM
meh, that's not a new insight, just something I'd forgotten
 
since you have forgotten it it will now be new to you
 
@DeadMG Welcome to the world of Alzheimer's!
 
no, it's just now a "Oh, yeah, forgot about that."
@FredOverflow Nah, it's the world of "I wasn't really paying attention last time due to the extreme irrelevance of this trivia, and therefore did not think to store the information."
 
It's not a very interesting insight either.
 
It's interesting that you can forget and yet still know something at the same time.
 
4:23 PM
lol
@FredOverflow that's called the "I knew this already" syndrome
I will give you a hint for my specialization question of yesterday:
 
any of you guyz willing to donate your STL code for learning?
 
You only need to name the bare template parameters. No SFINAE, only type parameters nekkid names in the foo<...> list in the specialization!
 
it can be any simple application
 
but you need to do it in a special way haha
 
@MrAnubis You can look at the STL code of your standard library, it's all header only.
 
4:27 PM
technically, they could link specializations from a DLL
I believe that the MSVC CRT does this
 
Okay, but the primary template definitions are still there.
 
yes
oh, by the way
 
@MrAnubis If you're serious about learning the STL, why don't you buy some books?
 
I'm introducing ambiguity by allowing both a conversion to and a construction from, right?
 
@FredOverflow actually i want to learn using STL in appz(by seeing someones code) , not internals of STL ( will be too harder for me)
@FredOverflow i am reading from ebook these days :)
 
4:28 PM
struct A { A(const B&); operator B(); }; struct B { B(const A&); operator A(); };
 
@MrAnubis Then you want this:
 
@FredOverflow it has lots of sample codes?
 
@MrAnubis let me see...
 
or some sample applications using STL at large
 
@DeadMG if you now do extern B b; A a = b;, it will invoke the conversion function B::operator A. please explain why it is preferred!
 
4:31 PM
@MrAnubis From a quick skimming, there seems to be example code on almost every page, at least 80% of them.
 
and please explain why if you change the declaration of b to extern B const b; it will be ambiguous!
 
@JohannesSchaublitb Why would I explain it?
 
@DeadMG You have to earn the 100 dollars!
 
because then I give you 88 cents.
 
@FredOverflow thank a lot, you've always been a great help )
 
4:32 PM
that's two precious literals
it will also give you insight into a particular dusty c++ coner!
 
Does it make cones?
 
haha
 
I hear you can't get fat by sucking ice
 
You were probably reading about frozen water.
 
because the energy you need to heat your body again after swallowing it will be as high or higher than the energy you get by using the calories of the ice.
hmm
 
4:35 PM
There isn't much ice in an ice cream.
 
they were talking about sweet ice
 
How much colder does your entire body get from eating ice? How much calories does ice have? How many liters of water are in your body?
Ice seems to have about 100 kcals, so it gives you the energy to make 100 liters of water 1 degree hotter. Suppose you have 40 liters of water in your body, then the ice would have to make you 2,5° colder. Does it really do that? I strongly doubt it.
Compared to the 40 liters of water in your body, the mass of the ice is almost negligible.
 
hmm
im not a physicist. dunno about those calculations
 
I only used division :)
 
Woah.
 
4:42 PM
if you let the ice flow down your throat while it's still cold it will cool down all your throat and possibly your stomach
so it will all need to be warmed up
 
It won't matter a bit where exactly the ice is once it is in your system.
 
i would think that on warm places it has more effect than on already cool places
hmm
 
it's just an energy flow thing.
 
anyway need to leave
 
For example, putting four ice cubes in the same corner of a pool will give the same end result as putting each one in a distinct corner.
@JohannesSchaublitb buying ice? ;)
 
4:44 PM
The ice will get heat from your body as a whole system, regardless of where exactly
 
right
 
anyone registered on codeplex?
 
Damn, I still need to get groceries, and my motivation is 0.
 
5:01 PM
++fred.motivation;
Does that help?
 
cpx
@RMartinhoFernandes is it a public member?
 
I'm a friend.
 
Just divide your time by your motivation. Then you won't have to worry about those groceries anymore.
 
cpx
oh
 
> Twenty to fifty percent of hypothermia deaths are associated with paradoxical undressing. This typically occurs during moderate to severe hypothermia, as the person becomes disoriented, confused, and combative. They may begin discarding their clothing, which, in turn, increases the rate of heat loss.
Silly.
 
5:17 PM
@HostileFork One does not simply divide by zero.
 
5:42 PM
NSFW, if anyone is at work on Saturday.
 
@RMartinhoFernandes do you know of Java anonymous classes?
I keep asking this question a lot. Ha, Hi btw
 
I saw this at work.
 
5:58 PM
@RMartinhoFernandes Apparently, it did. Now I'm back, and the potatoes are on the stove.
Well, inside water, and the water is in a pot, and that is on the stove. But you get the idea.
@LewsTherin What about anonymous classes? Maybe I can help.
 
@FredOverflow hi
I posted this question
0
Q: The Anonymous Class Conundrum

Lews TherinI think I understand the basics of Anonymous classes but I'd like to clarify something. when I have a syntax such as this class A { class AnonymousClass1 Implements ActionListener{} } class A { public A() { JButton btn = new JButton(); btn.addActionListener( ne...

but there is a part I want to clarify
btn then calls the addActionListener() method which actually passes something like this btn.addActionListener(new AnonymousClassOne()) AnonymousClassOne a generic name given by the compiler
 
Why do you have two classes named A?
 
That static_assert question is funny.
 
Am I the only one who finds it hilarious that Java on one hand prohibits operator overloading because it's "confusing", and on the other hand, defines an operator>>> because, well, because they can?
 
@FredOverflow It was to show whether one is the same as the other
In theory I believe it is..
 
6:01 PM
@jalf They had to, because Java has no unsigned types, yet sometimes you want unsigned semantics on integers when doing bit operations.
 
The inner class in the first one is not anonymous.
 
@FredOverflow but why does it have to be an operator? Woudn't it have been more in the spirit of the language to define a static method somewhere?
 
@CatPlusPlus I know, but I think the compiler generates a generic name to use
 
@LewsTherin Oh. It's really confusing to name a class AnonymousClass1 :)
 
so maybe in a way it is nested
 
6:02 PM
@CatPlusPlus Recently woke up, did I miss something?
 
adding a new operator whose usage is not clear unless you look it up, seems just as confusing and unintuitive as allowing overloads of existing operators
 
Yes, the compiler generates a name, usually with a $ sign in it so you get no name clashes with user-defined names.
@jalf I don't agree.
 
3
Q: static_assert - a way to dynamically customize error message

smallBIs there a way to make static_assert's string being dynamically customized and then displayed? What I mean is something like: //pseudo code static_assert(Check_Range<T>::value, "Value of " + typeof(T) + " type is not so good ;)");

"Use a macro! Use a macro!" lol.
 
@FredOverflow Yeah, so isn't it technically a nested class of class A?
as in the first example?
 
@LewsTherin It is, otherwise you'd have no access to A's members inside the anonymous inner class.
> If the anonymous class is actually an outer class of class A, as in the first example
What do you mean, "outer class"? Looks pretty "inner" to me, you define it inside of A.
 
6:05 PM
Damn it was inner class. Maybe the dude Mat changed it lol
or maybe I made the error
 
@CatPlusPlus Downvoted for his/her own good.
 
I downvoted to make my rep divisible by 5.
But your reason is good, too.
 
@FredOverflow I actually want to clarify this reasoning
When an object of A is instantiated it creates a button object, btn then calls the addActionListener() method which actually passes something like this btn.addActionListener(new AnonymousClassOne()) AnonymousClassOne a generic name given by the compiler.
 
0
A: The Anonymous Class Conundrum

FredOverflowclass A { public A() { JButton btn = new JButton(); btn.addActionListener(new ActionListener() { ... } ); } } is more or less rewritten by the compiler as class A { class SomeCuteName implements ActionListener { ... } public A() { ...

 
I think that is what it does, although we see it differently...
 
6:07 PM
@CatPlusPlus Was modulo 3 before the downvote so it doesn't hurt that.
 
Bah, Java. Anonymous classes are poor workarounds.
 
@FredOverflow answers my question an upvote :P
and thanks :)
@CatPlusPlus why?
 
Because you can't pass methods around in Java.
So you have to invent dummy objects.
 
Speaking of, anyone knows what the "blahblahblah function types" excuse was about when they justified delaying lambdas?
 
@CatPlusPlus C# does the same thing under the hood, but with much nicer syntax.
 
6:11 PM
@CatPlusPlus we can't have anonymous functions?
 
@LewsTherin not until Java 8, nope
 
What, Javascript does that... how weird
 
@FredOverflow Well, it's the syntax that primarily matters.
0
Q: try catch finally construct - is it in C++11?

smallBDoes try/catch/finally construct is supported in C++11? I'm asking because I couldn't find anywhere information about it. Thanks.

Dupe.
 
@LewsTherin So what? JavaScript is not Java. Just as C++ is not C. (Or even more so.)
 
@CatPlusPlus Arguably not, since that's about C++11. It's related though.
 
6:15 PM
@LucDanton The concept didn't change, it's just that the FAQ entry needs a note about it.
 
@FredOverflow Yeah.. I guess so. But since Java is a purer OOP language than Javascript I'd expect it to have
 
Java is pure bullshit language.
2
And JavaScript isn't that much further behind.
 
@LewsTherin how do you define pure OOP-ness?
 
@LewsTherin In my opinion, JavaScript is much more interesting than Java.
 
Isn't it more true that "everything is an object" in JS than in Java?
 
6:17 PM
@jalf A pure OOP language has no interesting concepts, just the usual encapsulation/inheritance/polymorphism stuff.
@jalf "more true"? :)
 
Java classes certainly aren't objects. JS seems purer because it doesn't have them
 
I don't think JS numbers are objects.
And Java classes are objects, AFAIR.
 
@CatPlusPlus but neither are Java ones, afaik
 
There's Foo.class.
 
@CatPlusPlus Hardly the same thing. Can I pass a class as parameter to a function?
anyway, neither language seems very "pure OOP" imo
but JS is definitely a more interesting language
Java was practically designed to be uninteresting
 
6:21 PM
JS has brain-dead typing. Writing anything in this language is a pain.
Even more so than in Java.
 
agreed
 
I disagree :)
 
And idiotic things like not enforced signatures.
It feels like Perl.
 
int should be an example good enough as to why Java is not pure OOP.
 
I prefer static typing, but JS is a pretty good attempt at a dynamically typed language
 
6:24 PM
I can work with both static and dynamic typing. But not with weak dynamic typing.
function foo(a, b, c, d, e) {}. Guess what happens when you call foo().
I'll tell you what. Nothing. All of the arguments are just undefined inside the body.
 
Go on.
 
hmm? Why would you expect anything to happen when you call a function with an empty body?
perhaps I'm missing the point here
 
No, no, it's not about the body.
It's about the arguments.
You call 5-argument function with no arguments.
Let's say it was a typo.
 
ah, gotcha
 
That's par for the course. Case in point: nil.
 
6:27 PM
Dunno, it's quirky, but not really something that's going to keep me awake at nights
 
JavaScript just goes "meh" and carries on.
It's like Objective-C's ignoring of non-existent methods.
 
you're in a C++ chat room. A few quirks aren't going to scare anyone off
I was surprised to read in an interview with the Gosling guy that Java was inspired by Obj-C btw
 
Okay. Is "0" true or false in JS?
 
I thought obj-c was much more recent
 
@CatPlusPlus That's quite OOP, isn't it?
 
6:28 PM
@LucDanton I don't know. It's stupid to me.
 
Unless there's no way to override this behaviour.
 
@CatPlusPlus false, I think. I can't remember exactly :)
 
@CatPlusPlus Send a message to an object, let it handle it. Seems like 'default' handling is ignoring it. If the behaviour is overridable that sounds very OOP to me.
 
But again, does it matter? Is it worse than 0123 being an octal literal in practically every language?
 
For me default should be to bail out.
 
6:30 PM
I'm just saying that for all its quirks, JS also has some genuinely interesting/nice features
 
It's all about making your life easy vs making your life hard in case of mistakes.
 
Which is much the same reason why I like C++ as well. It's hopelessly flawed in oh so many ways, but it also contains a handful of genuine gems
 
sbi
@RMartinhoFernandes I (think I) understood that. What I am saying is that, what he calls ranges is, in other libraries and languages, called iterators.
 
I've debugged tons of problems related to JS stupidness.
 
(I mostly care about the overridable part. What the default behaviour should be sound like a religious debate.)
 
6:31 PM
Especially those signatures.
 
@CatPlusPlus No doubt. But haven't we all also debugged tons of problems related to C++ stupidness? ;)
 
No, this is compiler-level debugging.
 
sbi
@jalf Not me. (Mine would have to be measured in megatons.)
 
Also, JS has no default arguments.
 
@CatPlusPlus that's a weird argument. Every language lacks some features that other languages have
JS doesn't have templates either
 
6:32 PM
@CatPlusPlus If that's your thing default Lua behaviour when calling a non-existant 'method' is to bail out, and it's overridable. Although when calling anything with less arguments than the signature you get nils.
 
on the other hand, C++ lacks proper closures, even in C++11. JS has those
 
For me the whole point of having signatures is to use them.
 
@CatPlusPlus JS uses them too. It uses them to bind function arguments to named parameters
 
I don't know about JS but in Lua the important thing is that a thing is callable, not that it conforms to a signature. You get poor man's overloading and poor man's default arguments with that, too.
 
And JS for me means browsers, and browsers are an inconsistent pain in the ass to deal with.
I just don't see any compelling features in this language, only annoying quirks you have to watch out for.
 
6:35 PM
@CatPlusPlus well, I'm talking about JS running in a sane environment. Browsers are a pain, no doubt about that :)
 
std::auto_ptr<Foo> foo = CreateFoo();
process(foo);
LogFoo(*foo);
^ Bug
Is this prevented with unique_ptr?
 
The need to write freestanding functions that accept smart pointers should be low.
 
std::auto_ptr is the bug.
There are better imperative languages. There are better functional languages. Why bother with JS?
 
@CatPlusPlus how do you define "better"?
 
Not annoying.
 
6:36 PM
@StackedCrooked Depends what the 'bug' is. One can still write a function that accepts a smart pointer and write process(std::move(foo)); *foo;.
 
Also, this in JS, another thing you have watch out for.
 
I know :)
 
CoffeeScript looks nicer.
 
@LucDanton I see. Ok, if I explicitly move the object by calling std::move, then I should not complain about not being able to access anymore.
 
@jalf Why do people worry about languages being "pure", anyway? Aren't impure languages much more interesting?
 
6:38 PM
@CatPlusPlus : Nice (theoretical) points, but is there actually an alternative when it comes to (well supported) browser scripting?
 
JS has a pretty nice mix of imperative and functional features. I can't think of another language which requires as little boilerplate code and offers the same functional and imperative languages that I care about, while also being widely available and usable in a range of different environments.
 
@KillianDS You can use a better language that's compiled down to JS.
 
@StackedCrooked Yes. After calling std::move on anything one has to be careful about what to use on the object after that. A common operation that should be available no matter what is assignment (as usual though, that's not enforced).
 
@FredOverflow All I know is that I find impure girls more interesting than pure ones.
 
Also, I've noticed I'm drifting towards all static typing, lately.
 
6:40 PM
@CatPlusPlus Don't we have JSLint to detect stuff like that?
 
@CatPlusPlus: are there such compilers?
 
@KillianDS GWT compiles Java to JS. Dart implementation has JS compiler. Pyjamas compiles Python to JS. CoffeeScript is mostly about that, too.
Dart is meh, but still.
 
Nice to know
 
sbi
> 1. A developer may not injure Apple or, through inaction, allow Apple to come to harm.
> 2. A developer must obey any orders given to it by Apple, except where such orders would conflict with the First Law.
> 3. A developer must protect its own existence as long as such protection does not conflict with the First or Second Law. – Jeff Atwood about Apple: http://www.codinghorror.com/blog/2011/10/serving-at-the-pleasure-of-the-king.html
 
@CatPlusPlus Then you have to read "JavaScript: The Good parts". It really changed my mind about the language.
 
6:42 PM
JS is flexible enough that you should be able to compile nearly every language down to it, without much problem.
But it's not nice enough to be written by hand.
 
sbi
I hate murkdown.
 
@CatPlusPlus Because JavaScript is the most popular programming language; everybody has a browser. If you know JavaScript, you can reach almost every person in the world.
 
@FredOverflow Again, you can leverage the platform, as horrible as it is, with a better language compiled to JS.
 
sbi
Another interesting quote from the same source:
> That's the problem with kings, you see. Their rule is absolute law, but they can be capricious, erratic, and impulsive. If you're lucky enough to live under the rule of a fair and generous king, then you'll do well. But historically speaking, monarchies have proven to be...unreliable.
I wish he'd apply this to himself. :)
 
@FredOverflow Well, I don't care about JS enough to read a book about it.
My experience was a pain and hours spent on stupid bugs that could be prevented on a language level.
This kills the language.
 
6:46 PM
So, are you getting paid for doing web stuff lately?
 
Oh okay. Hence the loss of sanity points.
 
sbi
2 days ago, by Cat Plus Plus
One thing I'm sure about is that I don't want to be a web developer.
 
@FredOverflow Interesting, or useful? ;)
 
@CatPlusPlus Okay, then watch a video. It'll only take one hour of your life.
 
6:50 PM
@sbi Mostly because of JS and browsers being absolute shit.
 
The speaker is really good. Too bad he is not a C++ programmer :)
 
sbi
@CatPlusPlus I can relate to that (there's a reason I remembered that statement), but what I wonder: If you get paid for doing web stuff, why do you think you would have to become a web developer? You already are one!
 
@sbi Okay, "I don't want to remain a web developer for very long".
 
let's see if I can wrestle the chat's markdown into submission
> 1995 - Brendan Eich reads up on every mistake ever made in designing a programming language, invents a few more, and creates LiveScript. Later, in an effort to cash in on the popularity of Java the language is renamed JavaScript. Later still, in an effort to cash in on the popularity of skin diseases the language is renamed ECMAScript.
 
sbi
@CatPlusPlus Yeah, that's what they all say – right until the pension... :)
 
6:53 PM
You can do server-side web dev in C++.
 
@FredOverflow thanks, will definitely watch
 
sbi
@StackedCrooked maybe, but why would anyone want to do that?
 
> JavaScript is not held in very good esteem, even within its own programming community. For example, the C# community loves Anders, and the Java community loves Gosling, and the PHP community loves Rasmus.
> But in the JavaScript community, there is no love. And there should be. I think it indicates a lack of understanding. JavaScript is still the world's most misunderstood programming language. It's the only language that I am aware of that people feel that they don't need to learn it before they start using it.
 
@sbi I did a small webservice in C++. It was fun.
 
@FredOverflow the last part is true for java too, imo
 
sbi
6:56 PM
@jalf Unfortunately, it even true for C++ far too often.
 
fair point
 
> JavaScript is basically Scheme with C syntax.
 
:)
 
sbi
"People say they're in love with C++ and they say it with a straight face. I've never met anyone who's in love with C#." -- Kate Gregory
 
@sbi I agree :(
How can you not love all the neat features of C#?
 
sbi
6:59 PM
@FredOverflow It seems we should introduce you to Kate. :)
 
@FredOverflow there's a difference between loving individual features and being in love with the language as a whole
 
Every year it gets a wheelbarrow of new features. How can you now love C#.
 
sbi
@jalf Good point. I failed to see that.
 
> The DOM is one of the worst APIs ever imagined.
 

« first day (364 days earlier)      last day (4575 days later) »