« first day (386 days earlier)      last day (4563 days later) » 

4:00 PM
What modules does CS have for example?
 
@LewsTherin You can see for yourself here, or rather here.
 
@FredOverflow It's almost like ours then.. cool
What is Rechnerstrukturen?
 
I assume how your computer works and such
 
yes
binary numbers, buses, instruction sets etc.
 
Computer Architecture... cool
Obviously I didn't learn anything in that class lol
 
4:11 PM
all the way down to flip flops and transistors, a level I very rarely think about :)
BTW, I did tell you that I haven an "Oppenheimer" in my C++ course, right?
He used three gotos in the first assignment :)
 
lol
"Now, I am become Death, the destroyer of worlds"
Did you not advice him against gotos?
 
:)
I did, but since we hadn't even introduced any kind of control structures, I actually found it kind of cute.
 
sbi
"It's transistors all the way down."
 
> I used to have a goto in my pocket calculator, so I looked up if C++ also had a goto, and it did!
 
@FredOverflow Interesting, my lecturer was blue in the face regarding the use of gotos
 
4:15 PM
Well, our teacher will say stuff about goto... in about 4 weeks. I can't really blame him before then.
@sbi Pretty sure transistors don't consist of other transistors ;)
 
@FredOverflow I still don't know why they are bad. I have never used it, because he was so adamant about never using it.
 
@sbi the Wiki article is up now ;)
 
And I was scared lol
 
@LewsTherin Because gotos make your program impossible to reason about formally. That's the reason given back then by Dijkstra.
Not that anyone actually cares about formal reasoning in programs nowadays :)
Most people don't know why gotos are bad, they are just told so. Which I find worse than the goto statement itself.
 
sbi
@FredOverflow So the @Cat woke up?
 
4:18 PM
@FredOverflow Yeah, same with me. I don't know why it is bad
 
sbi
@FredOverflow Got a link?
 
oh yeah, and raptors of course:
@sbi It's stickied at the right with 5 stars ;)
 
sbi
@FredOverflow Oh, I missed that. Hangs head.
 
@FredOverflow I actually found that funny. Does a Sheldon laugh
 
Of course it's funny, it's XKCD!
 
sbi
4:20 PM
@FredOverflow Indeed, license agreements are so much cheaper to come up with that formally testing your code, so they have taken the place of formal reasoning.
 
gotos are used quite a lot in C for error handling, or so I've heard.
 
@FredOverflow Apparently gotos are bad as break
 
There are even people that say "OMG your function has two return statements, you need to introduce another variable". "But won't that make my program longer and harder to read?". "Yeah, but then you only have one return statement!". "So?"
 
sbi
@LewsTherin No, they are much worse. Many keywords essentially perform what goto does (if, while, return,...), but in a much more restricted form.
 
hi
 
4:22 PM
@sbi breaks are worse?
 
breaks jump to the end of the control structure. You can't nilly willy jump anywhere. So they're nowhere near as "bad".
 
@FredOverflow I don't get that.. why introduce another variable...
@FredOverflow Yeah, what I thought..
 
sbi
@FredOverflow That Single Entry, Single Exit is a leftover from the times people used assembler. You had so much freedom then, you needed to restrict yourself. Those restrictions, however, do not necessarily overlap with the restrictions that are useful today, when we use more structured languages.
 
@DeadMG hello
 
@LewsTherin Well, compare
int min(int a, int b)
{
    if (a < b) return a; else return b;
}
with
int min(int a, int b)
{
    int result;
    if (a < b) result = a; else result = b;
    return result;
}
but personally, I prefer:
int min(int a, int b)
{
    return (a < b) ? a : b;
}
 
sbi
4:24 PM
@LewsTherin "Gotos are bad as break" "No, they are worse." "Breaks are worse?" What's happened to your reading lately?
 
no!
? : is badness
 
@FredOverflow Me too. But I prefer the first one. No need for a third variable
 
return a; else return b; is the better way
 
?: is fine in the right places
 
@sbi I'm hungry.
 
4:25 PM
@DeadMG ?: is a perfectly fine language feature. It just looks ugly to the uninitiated. In Scala, ?: is called if then else. It does the same thing. Is that badness, too?
 
sbi
@LewsTherin I detest being eaten.
 
it behaves differently with references
 
@sbi What makes you think I care? :)
 
and there are some places where you really need it, e.g. const Foo& f = b?f1:Foo();
 
consider the case where you have Base& and Derived& through templates
 
4:26 PM
@DeadMG It does? In C++, c?a:b can be an lvalue.
 
sbi
@LewsTherin Let's not go there.
 
the ? : version returns a Base. The return a; else return b; can return a Base&.
 
Are you sure? I wouldn't be surprised if it were Base&.
 
it was on the msdn blog about rvalue references
because they ran into exactly that problem when they first implemented the new C++11 std::min
and they said "Now, our std::min behaves better than the old C min macro"
for this reason
 
sbi
@FredOverflow That page needs a linking TOC at the top. And the welcome page now needs pointers into the existing pages.
 
4:28 PM
after they changed it away from ?:
 
Base a;
Derived b;
std::cout << &((rand() & 1) ? a : b) << std::endl;
This program compiles, how do you explain that? & only works on lvalues.
 
the problem isn't with that
what are you going to get if you decltype that expression?
 
I don't know, let me try...
 
it's just like *ptr, technically, is not a reference result, even though logically it really should be, but it's still an lvalue
 
Base a;
Derived b;
static_assert(std::is_same<decltype((rand() & 1) ? a : b), Base&>::value, "oops");
Compiles fine, so it's a Base& I guess? Is that a problem?
 
4:31 PM
Ok I am going to eat... Fear not @sbi
 
on what compiler? I know that MSVC10 has a habit of completely ignoring static asserts
 
g++ 4.6.1
If I leave out the ampersand, I get an error.
 
and, more to the point, even if you have one implementation that behaves that way doesn't make it Standard for it to be that way
 
Right, let me browse through the standard...
 
or maybe they just corrected it, I guess- that blog would have been from a while ago
enough time for them to file a DR and fix it
 
4:32 PM
I'm done downloading QT, installed it. Now i need some good resources where to start , books or video tuts etc for beginners in QT?
 
@user411102 - I started with the examples directory
1
Q: Qt tutorials for beginners

Med-SWEngI want to ask about resources for learning Qt for beginners. What resources do you recommend for that? Thanks.

 
@awoodland Thanks for link , looks like their docs are best place to start
 
@DeadMG 5.16 §3 point 1 seems to agree with me.
 
ok
 
So may I use ?: now without fear of little puppies chasing me? ;)
 
4:36 PM
lol
I might forgive you
 
I still think it's a sin, and would cut it from the language in a heartbeat
but I guess that it's not actually technically wrong, as far as I can tell
 
I think it's a useful way of making the code readable by keeping the emphasis of a statement on the parts your care about
 
also, I've been thinking about a new template class
how about a ranged_integer<lower, upper>?
 
You mean class template?
 
4:38 PM
when you define one, first you say template, then you say class
so the Standard guys can call it whatever they want
 
If you don't care about the standard, why did you just make me hunt down the relevant ?: paragraph?!?
 
uh
the difference between "template class" and "class template", especially in an informal setting like this, is trivial at most
whereas if I was correct, then using ?: in the wrong way could lead to some nasty surprises
 
Isn't a template class an instantiated class template or something? :)
 
@DeadMG - I'm tempted to ask if you meant define or declare in that statement too :)
 
lol
aanyway, going back to the point at hand :P
 
4:40 PM
Seems useful, I think Pascal had those range types built into the language.
 
I think that a ranged_integer<lower, upper> would make for a great class
it would offer almost complete protection from overflow
 
@DeadMG - it's on my dissertation topics list :)
but I think it might actually have happened
 
lol
 
How would you implement ranged_integer<0, 0xffffffff> to protect from overflow? Use an underlying 64 bit type?
 
it's actually quite hard to do portably though
 
4:42 PM
@FredOverflow You could just throw a static assertion if the range goes out of range of a potentially unsigned 32bit int
 
you have to re-implement all of the operators and spot operands that would cause an overflow to do it portably
 
Too bad we can't query the carry and overflow bits from within standard C++ :)
 
@DeadMG - needs to be runtime really to be useful, not static assert
 
no
 
@DeadMG But the range is fine in that example, it's exactly the range of a normal int. But you promise "no overflows!", how do you do that?
 
4:43 PM
because the compiler always knows the maximum value of the result of any operation
and therefore can always guarantee to have a type ready to store the result
 
but the maximum isn't always useful
 
But then you cannot even add two ranged_integers :)
 
of course you can
 
not without increasing the range
 
right
I couldn't say a = a + b;
 
4:44 PM
ranged_integer<l1, u1> + ranged_integer<l2, u2> = ranged_integer<l1 + l2, u1 + u2>
 
which means that your PID controller that needs to output between 0 and 512 for a servo can't be neatly expressed
 
So all ranged_integer objects are immutable?
 
no, their ranges are, though
 
the more useful semantics are runtime exceptions
 
however, you can do a = a + b, if you're OK for a run-time exception
 
4:44 PM
But again, how would a = a + b work if a + b has a higher range than a?
 
but since they're two different operations, I see no reason not to do both
 
You could also ditch all numeric types except double, because double overflows very rarely. I'm looking at you, JavaScript!
 
lol
long long also overflows very rarely, but that's not really the point :P
 
double overflows even very rarelyer!
 
the point is that the ranged_integer class guarantees no overflow, no underflow
 
4:47 PM
loungecpp.wikidot.com server is slow on my side or everyone facing similar problem?
 
for free at compile-time, too, if you don't deal with unprotected values
infact, I'm going to write that class right now
because I can
 
@user411102 works fine for me
@DeadMG have fun
 
thanks
 
if you don't deal with unprotected values, and the range is always changing...what's the use of it?
 
well, a, you always get the smallest possible type to express the range
 
4:48 PM
Forget the use cases, he already said "because I can".
 
@FredOverflow anyways , who created the wiki?
 
whereas the language has really liberal, and strange, promotion rules
 
@user411102 I suppose our only admin, @Cat Plus Plus.
 
and b, it's safe
 
@DeadMG - I think I already have addition and multiplcation code which can portably detect overflows with arbitrary ranges somewhere if you want :)
 
4:49 PM
but then I wouldn't be able to code it myself
damn, I really need a compile-time logarithm
 
You could also write an arbitrary precision integer. Then all problems would go away forever!
@DeadMG What base?
 
2
 
That should be easy.
 
but arbitrary precision integers are f'in slow
yeah, I know
 
use constexpr for it :)
 
4:53 PM
trying to write a template that will create an integral type large enough to store the range, for any range of a known size
maybe I'll just write a few specs and that'll be easy enough
now I've completely and totally forgotten how to write a partial specialization
 
Something weird just happened. I have 2 variables. A char **s which points to an array of pointers to string as you know. And a char *p
I did char *p = s; printf("%s", *p) But it didn't work...
If s points to an array of pointers. s points to the first pointer. I assign that to p
*p should give me a valid string
 
5:09 PM
I'm slightly surprised that would compile as you describe
 
I'm amazed that compiles as you describe
 
You cannot assign a char** to a char*.
 
I am as well. But gcc allowed it
 
because you've definitely messed up your indirections
 
It's how you write char **s = {"hi", "world"}; that confuses me
unless you're calling malloc/new[]?
 
5:11 PM
he must be
that's a char*[], not char**
 
char **s = ptr->h_aliases ptr is of type hostent
 
array-pointer decay only occurs for the first dimension
it can't occur for the other dimensions
you often see newbies going char[][] = char**, which it most definitely does not
 
@LewsTherin Show us the definition of h_aliases.
 
Okay, that's char**. You cannot assign that to a char*.
Maybe you meant char* p = *s;?
 
5:13 PM
(which made me want an instance of struct galaxy called away so I could write galaxy FAR FAR **away)
 
@FredOverflow I tried that but it didn't work. What the hell is FAR FAR
 
@awoodland lol
 
@awoodland lol
 
@LewsTherin far pointers are from the 16 bit era. You don't wanna know about then, trust me!
 
@FredOverflow Gladly ignored! :)
 
5:14 PM
But if you ever write an OpenGL program and wonder why you cannot name your plane variables near and far, well guess whose fault that is!
 
@LewsTherin - you can have different addressing modes on some hardware. Some of the relative ones have maximum distances from what they're relative to)
 
He doesn't need to know!
 
lol
 
it's an interesting quirk
 
I wish I didn't ask now :(
 
5:16 PM
How do I know how long the h_aliases array is?
Oh wait, it's NULL terminated.
 
Yeah, I was wondering that, in the example it compared with NULL
So I assumed it was.
 
char* a[] = {"hello", "world", 0};
char** p;
for (p = a; *p; ++p) puts(*p);
 
I tried that but I get a seg error
 
Well, I don't. Have you copy/pasted my exact code and tried it?
 
Oh crap. I did s+=1
@FredOverflow No I didn't
Wait that shouldn't matter
 
5:21 PM
Then you most certainly didn't try it :)
 
But my code works on that concept lol
 
Maybe you can show us the actual code you are working on instead of a vague description.
 
I'm just playing around with bit twiddles, is there some way I can output the binary form of an int to std::cout ?
 
can you add some more consts in? By the sound of what you wrote some pointer that ought to be const aren't
 
oops
 
5:22 PM
Wait, you are using printf("%s"), but I don't think you have strings there:
 
> A NULL-terminated list of addresses for the host. Addresses are returned in network byte order. The macro h_addr is defined to be h_addr_list[0] for compatibility with older software.
 
h_aliases is a pointer to a pointer to a string
 
They can't be strings, because strings don't have byte order.
Are you sure they're strings and not IP addresses or something?
Oh wait, you're probably right. Strange.
    for (pAlias = remoteHost->h_aliases; *pAlias != 0; pAlias++) {
        printf("\tAlternate name #%d: %s\n", ++i, *pAlias);
    }
^ example code from the MSDN link
 
So why isn't it working for me? :S
 
5:25 PM
We need to see YOUR code.
 
I posted it ^^
 
oh :)
 
lol
 
line 30 should be while(*s!=NULL) instead of while(s!=NULL).
You're not gonna get a NULL pointer by incrementing s a few times.
 
That fixed it. I could have been staring at that for hours damn.
 
5:28 PM
draw a diagram on paper and it should be crystal clear
It's the same logic as printing the command line arguments btw:
int main(int argc, char** argv)
{
    char** p;
    for (p = argv; *p; ++p) puts(*p);
}
 
Thanks, I see why I was getting that
@FredOverflow I really am starting to hate pointers.
 
@LewsTherin Pointers lose a lot of their mystery once you a) start drawing diagrams rigorously or b) start programming in an assembly language.
There really is nothing magical about pointers. They're simply typed addresses.
Except for void*, those are untyped addresses :)
 
@FredOverflow Yeah it is easy for you :P
 
Because I have dealt with them a lot.
When I started using C, I was all like "WTF is this char* crap? All I want is a string!"
 
making mistakes makes it easier to spot mistakes
 
5:32 PM
And I was "Okay so arrays are pointers, but apparently not always, but that's what the books say, but there are exceptions, wait I don't get that at all..."
 
It seems like I will never get used to it. Some of the time I am ok with pointers
 
The thing that confused me the most was that * meant two different things. It marks pointers in declarations, and it dereferences in expressions. Of course all the books I had available sucked at explaining that.
 
For some reason that never confused me.
 
If you look at everything a human being can accomplish (like walking, speaking, writing, basic math...), then learning pointers is almost trivial in comparison.
 
Yum :) I just made caramelised onions in like 15 minutes
 
5:34 PM
sounds like a strange combination
Did you do it on purpose or by mistake?
 
@KianMayne Onions, ugh :(
@FredOverflow Maybe you are right lol.
 
@FredOverflow Caramelised onions are amazing!
 
@LewsTherin A pointer is like a URL, and the thing it points to is a website. And a bookmark is a pointer variable. Or something.
And you get 404 errors by dereferencing dangling pointers ;)
 
@FredOverflow Lol
 
And sometimes you get a weird porn page, because the webspace had been reused :)
 
5:36 PM
so porn is an example of UB then?
 
yes!
 
lmao!
 
@FredOverflow Brilliant analogy :L
 
Anything can be an example for UB, including porn :)
 
I might favour that over fire breathing dragons
 
5:38 PM
And a double pointer is nothing else than the URL of a website containing one link (or several links, if it's an array).
@awoodland unfortunately, you have no choice :(
Hey wait, "youtube" contains the word "ub"... I think we might be on to something!
And the comparative of "ub" is "uber"!
 
I really need to by that pencil
 
You can use MSPaint in the meantime.
 
I'm on Ubuntu. Don't know if it has paint
 
It probably has GIMP installed.
 
Nope, but I can get that. Cool :)
@RMartinhoFernandes hi
 
5:46 PM
Hi.
It's not Friday anymore.
 
It's Oracleday!
 
omg, h_addr_list points to a structure in fact
 
@LewsTherin Really? Why does the type system say char** then? Doesn't sound very typesafe :)
 
@FredOverflow Yeah, and it is very misleading.
 
Congratulations, h_addr_list just won the international Miss Leading award!
2
 
5:52 PM
Perhaps it's on purpose?
 
@FredOverflow rofl
@RMartinhoFernandes I bet it is. But it is still miss leading :)
 
I have no idea what an h_addr_list is, but sounds like a handle to an address list.
 
Especially to a novice
@RMartinhoFernandes Yep
 
1
Q: Is ->h_addr_list[0] the address I need?

slemdxI am working on implementing UpNP on C++, and I need to get the local internal IP address assigned by the router to make the sockets works. The address I need is the one that appears on routers where it shows the computers connected to the router and the local IP assigned to each computer. I am u...

relevant maybe?
 
Nice, thanks.
 

« first day (386 days earlier)      last day (4563 days later) »