« first day (106 days earlier)      last day (4835 days later) » 

sbi
12:02 AM
@AmirRachum See the bold text on the right featuring a link applying to this exact problem.
 
12:17 AM
hey, I have something like this in my code and I am getting an integer overflow warning showing when I compile:

long ans = ((long) INT_MIN) * 2 - 1;
I have
#include <limits.h>
here is the warning that I get:

warning: integer overflow detected: op "*"
 
@user475021 What architecture are you working on? Are you compiling a 32 bit binary?
 
SunOS sol 5.10 Generic_137111-08 sun4u sparc SUNW,Sun-Fire-880
what do you mean by if I am compiling a 32-bit binary
 
@user475021 :) I am not familiar with that hardware, the question is because depending on the platform/compiler/options (in particular when compiling for 32bit architectures) the sizes of the different types differ. In particular, in linux 32bit, int and long are both 32bits, which means that INT_MIN*2 is actually overflowing the type
A simple test that you can carry would be checking the output of this program:
#include <iostream>
int main() {
std::cout << sizeof(int) << std::endl;
std::cout << sizeof(long) << std::endl;
}
If both outputs yield the same result that will mean that in your system both types can hold only the same range of values
 
they both yield 4
thanks alot
 
12:46 AM
Try with long long, if supported as an extension in your compiler, as that increases the size to 64 bits in some architectures.
 
 
1 hour later…
2:13 AM
Last Call! Get the C++ Concurrency in Action (http://bit.ly/g2hY4Y) ebook for just $15! Use code dotd0129tw.
It's a very good book: it's both well-written and fairly comprehensive. At $15, it's a steal.
The author obviously knows what he is talking about. ;-)
 
2:39 AM
@JamesMcNellis In case some people don't realize how it's obvious: The author (Anthony Williams) is a C++ standard committee member, and wrote most of the threading section of the C++ 0x standard. He's also the author of the Just Thread library, which is probably the most complete implementation of that section of the standard (at least for now).
 
 
1 hour later…
3:56 AM
@JamesMcNellis isn't it a bit of a guess to write a book about C++ concurrency with C++0x when C++0x is not out yet? In the introduction he says "C++0x is due in 2010".
Also: I'd buy the duo, hard copy plus soft copy, if they were on sale!
 
4:14 AM
SO Elections remind me of elections at school: they make me feel bad for not being excited. :-S
 
5:12 AM
@wilhelmtell I don't think excitement should be the right reaction...
 
5:27 AM
@RamonZarazua I was paying attention to be very delicate in my language. I'm somewhat annoyed by this, to be frank.
 
what. the big orange bar that won't f#$ing go away?
i don't find it at all annoying. coff
 
5:56 AM
Hi, this isn't related to C. But I was wondering if anyone could tell me if there is a SEO equivalent of stackoverflow, where people can ask/answer questions pertaining to SEO?
 
@JerryCoffin Yeah, I probably should have explained why, but then we wouldn't have gotten your excellent "about the author" snippet.
 
@JohnMerlino Well, here in C++ chat lounge we only discuss matters unrelated to C++. Since your question is unrelated to C, instead of unrelated to C++, it's off topic.
 
@wilhelmtell It was slated for printing in September 2010, then has been delayed twice, probably because he doesn't want to publish an incorrect book. I know there have been a couple of changes (mostly minor, but a few major) to the C++0x threading facilities over the last year. I bought the ebook+hardcopy duo last June and am still waiting for my hardcopy :-D
@AlfPSteinbach You have an undistributed middle in your logic.
 
@JamesMcNellis thanks! led me to new fallacy site, fallacyfiles.org/index.html
@JamesMcNellis I always used nizkor.org/features/fallacies to construct my fallacies. Systematically.
hey, it has a nice *taxonomy of fallacies*. now we can practice more easily!
 
6:16 AM
So many fallacious websites!
As a requirement for my degree in philosophy I took a course in formal logic; it was probably one of the best and most useful courses I took. Unfortunately, it has also made reading editorials a very painful experience...
 
@JamesMcNellis Although much less formally, How to Lie with Statistics covers an almost amazing amount of the same ground (quite entertainingly, I might add).
 
@JerryCoffin I read Logic and Philosophy. It is a lot like Sipser's Introduction to the Theory of Computation in that it is very formal and precise, but also extremely accessible and easy to read.
I give up. I guess that isn't getting italicized. Thanks, Letdown.
 
@JamesMcNellis I'm afraid the course I took was so long ago I can't remember the name or author of the book (but I don't recall thinking particularly highly of it either).
 
6:32 AM
@wilhelmtell Oh, also, I'd wait if you want the duo. I got the ebook+hardcopy pair for half price in their fourth of July sale last year (well, really, I went overboard and got six books and ebooks at half price, but that's another matter altogether). They have quite a few sale special events.
@JerryCoffin I may have to get a copy of How to Lie with Statistics; I've heard it referenced many times.
 
i don't know how you do that! always, when I try the "take three, pay for two!" they stop me and accuse me of shoplifting. grumble.
 
@AlfPSteinbach Ha! It helps when you have their permission :-D
 
@JamesMcNellis well, i think it's deceptive marketing. they just take back two of the books. so then i'm left with "take one, pay for two!"
 
@AlfPSteinbach That's not too different from my "buy three, read one" strategy.
An epic review of Sipser's book: amazon.com/review/R2DQJIX84KLFU/… "all of the examples provided were outdated by at least 45-50 years. Some of the devices used in the examples no longer existed (like some pre-historic tape machines)."
 
6:51 AM
@JamesMcNellis LOL :-)
@tina a "please" wouldn't hurt, you know :-)
it's ok
 
 
2 hours later…
user379888
8:47 AM
When are static members declared in a class?Can anyone help me out
 
user379888
As the compiler reaches the statement terminator of the class?then?
 
9:14 AM
@fahad What do you mean when?
 
9:32 AM
(More modern music. Foo Fighters "The Pretender")
 
 
1 hour later…
10:59 AM
@sbi what link?
 
 
3 hours later…
user379888
2:16 PM
Hi
what is the difference between php and php.net
 
3:00 PM
@fahad The .net part, I guess.
 
Hi all;
 
3:48 PM
@karlphillip "Hi all" is not a statement. Hence there is no reason to terminate "Hi all" with a semicolon ;-)
 
4:15 PM
@FredOverflow Thank you, Fred;
 
sbi
5:11 PM
17 hours ago, by Amir Rachum
Hi all. Not sure how the chat works, but I would appreciate some help with doxygen (http://stackoverflow.com/questions/4840145/doxygen-warning-no-uniquely-matching-class-member-found-for).
Nov 18 '10 at 9:16, by sbi
If you're new here, read the newbie hints.
@AlfPSteinbach LOL!
 
5:32 PM
@FredOverflow "Hi all" is a declaration, not a statement -- but a declaration still needs to be terminated with a semicolon.
2
 
sbi
@AlfPSteinbach Oh well.
 
@JerryCoffin It could be a declaration-statement, in which case it is both! (It still needs a semicolon though).
 
6:06 PM
lol
 
@JerryCoffin Does that imply we are of type "Hi", and nobody knew about us prior to the "Hi all" declaration?
Or, if "Hi all" is even a definition (which I believe, since there is no extern), did we not even exist prior to the "Hi all" definition?
 
sbi
@FredOverflow What if "Hi" actually is void (*Hi)(), isn't Hi all; then a declaration?
 
@sbi I don't think so. After all, it is a variable that gets memory associated with it by the definition, right?
 
sbi
@FredOverflow Ah, you're right, that would define a function pointer variable.
 
exactly
 
sbi
6:17 PM
Mhmm. I have seen function types (instead of function pointer types) used. (Like in std::function<void()). Can you declare a function using this?
 
I don't know, let me try...
@sbi Seems to work.
 
sbi
@FredOverflow Isn't that typical for C++? You ask a question about syntax, and people go off trying it on three compilers. Then they end up deciding which one was right...
 
typedef void foo();
foo x;
foo* p = &x;
void x() { }
There, that's the code I wanted to post.
Here, foo x; is indeed a declaration.
 
sbi
@FredOverflow See! <smug_look/>
 
Once again, the C++ terra incognita just got a little smaller for me :)
 
sbi
6:24 PM
@FredOverflow What's this one tiny island in that big ocean?
 
Function types ;)
 
sbi
6:53 PM
One of those questions where all you have to do is to remember where you read it, pull that out in time - and then damn yourself for it being on paper and you never having learned to speed-type: stackoverflow.com/questions/4844669 All in all very easily earned rep. :)
 
7:23 PM
@sbi Either that or answering... "Just 'cos" -- well... with some other text to overcome the 15 char limitation
 
 
1 hour later…
8:33 PM
 
sbi
8:48 PM
@DavidRodríguezdribeas I don't like "just because" answers for this kind of questions. There are always reasons why something is the way it is, even if it might just have been Stroustrup's personal preferences at the time he had to decide what to do first.
 
@sbi I was just kidding. The one professor I liked most at university was the one that never told us how things are, that you learn from books, but rather what decisions had to be made, what problems had to be overcome, why other approaches failed and why all that lead to the current solutions. The "what" is hardly as valuable as the "why" that led to that "what"
 
what even is a multimethod?
 
@DeadMG apparently the dynamic language thing "corresponding" to overload resolution, i.e. based on dynamic type of arguments
 
9:03 PM
interesting
don't really see the need though, that's what double dispatch is for
 
Dynamic dispatch based on more than one argument (as compared to only the implicit *this*). A language based solution to double (or higher) dispatch methods.

struct object {};
struct rock : object {};
struct ship : object {};
void collision( object&, object& );
void collision( rock & r, ship & s );
int main() {
rock r_; ship s_;
object &r = r_, &s = s_;
collision( r, s ); // dispatched to collision( rock&, ship& ), not collision( object&, object& );
}
@DeadMG Exactly, double dispatch is a (limited) form of multimethods, and not supported in C++ either.
 
sure it is
struct rock; struct ship;
struct object {
    virtual void collision(object&);
    virtual void collision(rock&);
    virtual void collision(ship&);
};
struct rock {
    virtual void collision(object& obj) {
        obj.collision(*this);
    }
};
whoopsie
I only showed some of it, but you get the point
 
:) You can work-around the lack of support for double dispatch by adding quite a bit of extra code to the hierarchy, but that is not supported by the language. In the same way that dynamic polymorphism is not supported in C even if you can do:
struct base {
void (*foo)();
};
struct derived {
struct base b;
int x;
};
 
not everything should be supported by the language
I mean
 
void base_foo() {}
void derived_foo() {}
base init_base() {
base b;
b.foo = &base_foo;
}
derived init_derived() {
derived d;
d.b.foo = &derived_foo;
}
//... some casting magic here and voilà, dynamic dispatch in C!
 
9:10 PM
how would you actually implement multi-methods for more than double dispatch or a couple of derived types?
you'd have dozens of combinations to write for
 
I cannot really remember, but I read a couple of articles not too long ago (by some measure of "long ago", probably about one year), let-me-google
 
yeah, I'm reading that
 
sbi
@DavidRodríguezdribeas Sounds like a very good teacher!
 
I didn't mean implement them, as in, how would you implement them by the compiler
but how would you implement them, as in, how would I actually sit down and write two dozen collision() implementations
 
Just write the collisions you need, and optionally a default collision for base types as a catch all safety net. Then the system magically dispatches to the best candidate and you get zillions of new questions in SO on why on earth did the compiler call this method instead of the one I expected?
 
sbi
9:15 PM
@DeadMG As you do now with methods depending on the runtime type of one objects (aka virtual functions): you implement them for the types you want special behavior for. Now you just do this for a combination of runtime types. Of course, you will run into the combinatoric explosion, but that's inherent to the problem, not the implementation in one specific language.
 
yes
that's why I suspect that the problem is not really worth addressing in-language
the limiting factors of how many you're actually going to dispatch to are high enough that existing boilerplate code probably isn't that big a deal
more importantly, it's very, very rare that I even come across existing double dispatch or a need for it
 
Some languages do support multimethods, and people accustomed to those languages miss it in C++ in the same way I cry out for "const" and real references when I have to code in Java
 
I know that .NET's dynamic type in .NET 4 is pretty powerful when it comes to this kind of thing
@David: I think there's a difference, which is that in C++, you can do multiple dispatches, whereas in Java you can't do const or real references
 
sbi
@DeadMG That depends on what you do. That collision problem is a standard example, and I suppose that, if you write such games, it is an actual problem to solve.
 
it's just uglier in C++
 
sbi
9:19 PM
If you never ran into something, there's usually the two possibilities that either you really never needed it or you didn't notice you needed it because you didn-ä-t even know a solution existed.
 
except that I'm fully aware of how to implement multiple dispatch
a mess that it is, though
 
Well, if you consider a hierarchy with a not-so-small number of elements for which collisions can be handled generically, with just a few of the combinations requiring special treatment, in a language with multimethods that is trivial to implement, but in C++ you would have to add the virtual methods to the base object for each derived type and possibly do a few other derived types.
Note that that also means that addition of a single class to the existing hierarchy will require recompilation of the whole set of classes, as it requires adding an extra virtual method to the base of the hierarchy...
Again, it is similar to virtual dispatch (polymorphism) in C, it does not require a rocket scientist, but it is not supported by the language.
 
9:34 PM
@DeadMG You can simulate const in Java with a "const interface" that is a supertype of the real type.
 
@FredOverflow That is a lot of work and it is rarely done in practice, sadly.
 
Everything that requires lots of work is rarely done in practice.
 
@FredOverflow Good, I did not think about that. In fact there are collection adapters that will do that. Also, @James, while most people will not implement them themselves, these type of adapters are present Collections.unmodifiableXXX
Where XXX is a type of collection. But the whole point is that not all languages support all features, but that does not mean that one given feature is useless just because a different language manages to work around the lack of the feature.
For some context, we were discussing multimethods and their lack in C++
 
Right.
 
9:50 PM
@DavidRodríguezdribeas Agreed, I'm so tired of people saying "Wait, Java doesn't have that feature, and Java works, so the feature must be useless!"
 
10:01 PM
especially since the "works" of Java is doubtful :P
2
 
10:24 PM
@DeadMG :D
 

« first day (106 days earlier)      last day (4835 days later) »