« first day (551 days earlier)      last day (4610 days later) » 

12:11 AM
> This message may be a scam
Really, Thunderbird? A draft I wrote?
12:31 AM
Well, are you a scammer?
Xeo
Xeo
Wtf is up with all those flags again...
More annoying is is it has a cap on how fast you can respond. So I can't just relinquish my duty as a 10k (or however much) user and ignore them quickly.
user1174868
Can anyone look at my code and tell me what is wrong?
12:43 AM
@Jordan Only one way to find out.
user1174868
user1174868
I don't know what "prog.cpp:39: error: invalid conversion from ‘int’ to ‘int*’" means
user1174868
That isn't helpful
tests[5] means "the 6th element of tests". tests only has 5 elements, making this wrong just by itself.
user1174868
okay so test[4]
user1174868
12:45 AM
I always get confused which one starts at 0
The bubblesort function accepts a first argument of type int* (int tests[] is exactly the same as int* tests, don't let yourself be fooled by syntax).
tests[4] is one element, so it's an int.
user1174868
hmm
user1174868
So int* means what?
It's a pointer to an int.
user1174868
and that is different from int how?
user1174868
12:47 AM
what is a pointer?
user1174868
good
Well, let's just say that you're passing one element to the function, when you want to pass "the whole array"
(I use quotes because that is a lie, but I guess it works until you know what a pointer is)
Xeo
Xeo
Jordan, for the sake of everyone in here and for your own good, get a book.
user1174868
I have a book but it doesn't address this
user1174868
We were told we would have to go online to find a solution to this problem, also no I do not get that
Xeo
Xeo
@Jordan Pointers basically store addresses of variables.
@Jordan Which book? Any half-decent C++ book will cover pointers.
Xeo
Xeo
IOW, it was a bad pun.
user1174868
Maliks Brief intro to c++
user1174868
12:51 AM
well I don't know pointers yet, and that isn't for another 4 chapters
user1174868
to use that bubble sorting function do I have to use a pointer?
user1174868
this just seems like an impossibly difficult exercise with what I know so far
I hate this. How can people think you can teach arrays without the student ever running into pointers? It's impossible! You have to not care at all for your students to not see that and decide to teach everything backwards.
Xeo
Xeo
@GManNickG You know, I'm wondering if an in-depth explanation of pointers could be left out if you just explain the heap as a giant container and pointers as iterators into it. Generalizing it, really.
user1174868
Well to be fair my school can't afford programming teachers, he is just the physics teacher
user1174868
12:54 AM
Yes arrays were explained like that
user1174868
like a matrix
@Jordan Oh, it's not about your school. This problem is all over.
Sadly.
Xeo
Xeo
@Jordan I don't want to ask why it even offers a programming course then...
user1174868
Transfer school
user1174868
so I don' spend 3 years getting my math done to transfer and then left with 3 years of programming :P
Xeo
Xeo
12:55 AM
@Jordan I'd rather see it as a giant hotel with a pointer being the key to a single room.
@Xeo Then you have to explain what an iterator is. :P
45 flags... is that a new record?
The flags are not gone yet?
Xeo
Xeo
@GManNickG Sure, but I think that's such an important and general topic (and not only applicable to C++) that it may be better.
user1174868
so for my function how can it work without a pointer?
user1174868
12:57 AM
void bubbleSort(int tests[], int n)
user1174868
I dont really understand but int tests[] is a pointer
Xeo
Xeo
Blame C, it's the same as int* tests
The quick fix is to just call it like bubbleSort(tests, 5).
Xeo
Xeo
But, here comes the quirk, only in parameters.
Like I said above, you want to pass the array, not a single element.
Xeo
Xeo
12:58 AM
It may be easier to just explain references and generalize that bubble sort to a template that takes a reference...
user1174868
I am not sure what the n is for actually, I copied the code from a website since there were no examples in the book
Xeo
Xeo
Cause getting into the details of pointers just to pass an array.. meh.
But something low-level under the hood understand metal something. Nonsense.
user1174868
I am going to order a new c++ book, what is the link?
1056
Q: The Definitive C++ Book Guide and List

grepsedawkThis question attempts to collect the few pearls among the dozens of bad C++ books that are released every year. Unlike many other programming languages, which are often picked up on the go from tutorials found on the Internet, few are able to quickly pick up C++ without studying a good C++ book...

user1174868
1:00 AM
thank you
Xeo
Xeo
@RMartinhoFernandes Did you try to make that a fucked up reason to explain pointers?
user1174868
oh shit that book is expensive
Xeo
Xeo
0
Q: Iteration, find

user1340113Please help! How would i find and remove leading underscores by iterating through looking at the characters and counting the number of underscores before a valid character occurs. As well as iterating backwards from the end of the string to find any trailing underscores. I can use the following...

@Jordan There are many.
@Xeo That's a summary of the "reasons" I hear for teaching the low-level crap first.
Rendered mostly the way I hear it, because it's all a bunch of "blah blah" with some references to understanding how something works or something.
Xeo
Xeo
Yeah. My counter argument is that you don't need to understand how an engine works to drive a car.
Or do you? I don't have a license.
1:03 AM
Xeo
Xeo
@Moshe "*Curse ALL the things" FTFY
@Xeo Here you do need to pass some basic mechanics exam for trucks.
Xeo
Xeo
Meh, trucks
But for most of the population, no, you don't need a clue about it, other than "put the key, it starts; shift gear, it moves"
Xeo
Xeo
Or how a processor and RAM works to write a text in Word
Might be a closer counter-example
user1174868
1:05 AM
its all magic
Xeo
Xeo
In any case, I'm off for now. Need to flip my sleep-awake cycle again to match the day-night cycle
user1174868
that is a weird way to think of it, you need to sleep the appropriate amount of time to be able to stay awake and efficient for your projected awake cycle
@Xeo My first programming teacher spent the first one or two weeks going over that: how a processor and RAM works. Not very deep, but just so people have the right expectactions about how programming works.
user1174868
So anynways, how do I make this work without pointers?
Without pointers? You'd use references.
I'm not sure if that helps.
Xeo
Xeo
1:07 AM
@RMartinhoFernandes I especially said "to write a text in Word", not "to program", since a basic understanding definitly helps here
user1174868
I dont know what a reference is
Sure.
@Jordan That's what I feared :)
Xeo
Xeo
@RMartinhoFernandes Global variables! /hide
user1174868
I have no idea how he expected us to do this, all we know is cin/cout, conditional statements, loops, functions, arrays
@Xeo Gosh, I didn't even consider that.
Xeo
Xeo
1:08 AM
You don't "know arrays" without atleast partially knowing pointers
user1174868
is it possible to print the array to variables and then I can run those variables through a sorting function and then print those?
@Jordan I suppose he expected you to do something like bubbleSort(test, 5).
Xeo
Xeo
@Jordan Since an array is just a bunch of variables tied together, that wouldn't really change anything
It uses pointers, but not in plain sight.
user1174868
that doesn't point to an array though?
Xeo
Xeo
1:10 AM
@RMartinhoFernandes I know, my mind is dirty. I'm sorry.
user1174868
Okay so that worked
user1174868
@RMartinhoFernandes I don;t know why it worked, but you are a wizard
Xeo
Xeo
Anyways, g'night
Xeo
Xeo
@Jordan No, he's a robot
user1174868
1:12 AM
robots can be wizards
@Jordan I could explain to you how it works, but it would involve explaining pointers, and, don't take this the wrong way, I really don't want to.
user1174868
sure
user1174868
I need to get a better book
user1174868
learning calculus and programming at the same time as a new language is really hard
Xeo
Xeo
And a better teacher
Yes, I'm gone now. I swear.
1:14 AM
lol
Can I ask what grade or whatever-they-call-it in your country are you in?
user1174868
ah crap, I am suppose to count from high to low not low to high
user1174868
Well I am really old
user1174868
I am 25, in my third year of college but I am a horrible person
user1174868
so really I am just starting school "level" wise
user1174868
I am having trouble understanding how that function works
user1174868
1:17 AM
while (swapped)
{ swapped = false; j++;
for (int i = 0; i < n - j; i++)
user1174868
Does that just cancel itself?
What do you mean by "cancel itself"?
user1174868
well the condition is only run when swapped is true, but immediately swapped is flase
Ah. The condition is only tested at the start of each iteration.
So it will continue to run at least until the end of the block, and only then will it stop, if swapped is still false.
user1174868
oh so it runs through all the if statements? and then turns into true again
1:20 AM
Yeah.
user1174868
so how does the loop ever end?
When the if that sets swapped back to true is not entered.
On line 67.
user1174868
oh ok
user1174868
so that is the sorting part
user1174868
it sorts the individual array values
1:24 AM
Yeah. It's a bit inefficient, but it's simple and it works.
user1174868
So I guess it works like this, it compares 2 numbers and then swaps appropiately, it then keeps running until no swaps are made?
What the hell, 45 flags?
hey, it's up to 60 flags now...
Ah hell naw.
taking another screenshot...
1:25 AM
Woah.
the hell...
@Jordan More or less, yeah.
@RMartinhoFernandes Heh
Note to self: passwords from different accounts are not interchangeable, not even if you try it thrice.
that and I've left the chat window open on another machine for a couple weeks. So it also has 270 pings... :P
user1174868
1:27 AM
what ahs 40 flags?
Once you reach 10k reputation, you get the "right" to be annoyed by people that like to play with the "flag as offensive/spam" system like little kids.
@Mysticial Geez, 272 name notifications?!
user1174868
I am intrigued at how much cheaper the kindle version of that c++ book is, anyone use a kindle for c++/programming books? not sure how well that would work
1:29 AM
@GManNickG I don't use chat much while I'm in my office. So it's been sitting on for a few weeks. I haven't posted a chat message from that machine in at least a month.
@Mysticial lol, excellent
273 pings :)
user1174868
@Mystical You go to University of Illinois? I was thinking of applying there for cs
I'll let it sit for a few more months and occasionally take a screenshot... see if it'll reach 1000 before FF finally implodes from its memory leaks.
@RMartinhoFernandes The way I see it, the last batch of flags was when two (I think it was two) people started talking in something other than English.
1:32 AM
@Jordan Yeah.
user1174868
How hard is it to get in?
I got in as a grad student.
user1174868
oh
Though I was also accepted when I applied here as an undergrad a few years back.
user1174868
Schools are so hard to get into, I can't get accepted anywhere
1:34 AM
Dammit.
*If you're wondering how I'm posting here without resetting that ping counter. I'm remote desktop'ed into my machine at work. But I'm chatting locally.
@RMartinhoFernandes Did you just like hack the source?
Used the JS console.
1:37 AM
$("#reply-count").html("1000")
If you set the flag count to like a million, will it overlap with the ping counter?
I can't see the flag counter now, so I can't play with it without too much hassle. I'm not exactly a JS user.
if it looks ugly, post it on meta: "Chat notification's broken when there are more than 1,000,000 flags."
And see how quickly you'll go double-digit downvotes...
I love how when the flags went from 45 -> 60 it just derailed the whole conversation...
@RMartinhoFernandes lol
user1174868
1:45 AM
It isn't released yet lol
:3356154 A new C++ standard was published last year, so there will be new editions of most of those books, yes. We try to update the list as often as necessary.
If you do find one new edition that was published recently, do tell :)
user1174868
Is this book any good? amazon.com/Structure-Interpretation-Computer-Programs-Edition/… it is for my next c++ class
Are you sure that's for a C++ class?
I've heard it's good, but I think it uses Lisp, not C++.
user1174868
yes I think so
user1174868
I just found that c++ book online for free, how is that legal? my.safaribooksonline.com/book/programming/cplusplus/0201721481
1:52 AM
You only get to see a preview there.
Like two paragraphs per chapter or something.
user1174868
oh
user1174868
Well I am probably going to buy this amazon.com/dp/0201721481/?tag=stackoverfl08-20
@Jordan You might want to hold off on that. The new edition (updated for c++11) is coming soon.
I haven't read it, but if it's on that list, it's good.
user1174868
Yeah I was wanting to review c++ over summer
1:57 AM
Nevermind what I said. It's not coming out until August I guess. amazon.com/Primer-5th-Edition-Stanley-Lippman/dp/0321714113/…
user1174868
I could just use my crappy book
Haha! Finally! It really works now! real victory dance
I can sleep now.
Good night.
2:30 AM
Whoa! Since when can GCC compile Java natively?
@Maxpm Since, like, forever.
That's awesome.
2:52 AM
@Mysticial: Does your Digit Viewer allow searches for arbitrary strings of digits? I haven't checked it yet. I'd like to search for, say, "987654321".
 
2 hours later…
4:42 AM
"The last message was posted 2 hours ago." Wow... and the flags still haven't went away yet: 75
@GManNickG No, but that should be pretty easy to implement once the source for the new Digit Viewer is released.
Sweet.
75 flags, 15 things each flagged by 5 people. If it gets to 7 each, then it go over 100. Looking forward to it.
I've been doing frequency counts on the 10 trillion digits (over and over again) as a way to verify that new Digit Viewer is good.
Even though the digit viewer doesn't support this functionality... the code for it is pretty simple:
YCDReader ycd(L"g:/Pi - Dec - 1t - 0/Pi - Dec - 0.ycd",1);
ycd.add_path(L"g:/Pi - Dec - 1t - 1");
ycd.add_path(L"h:/Pi - Dec - 1t - 2");
...

ym_uL counts[10];
memset(counts,0,10 * sizeof(ym_uL));

for (ym_uL c = 0; c < 10000000000000;){
    for (int i = 0; i < 1000000000; i++)
        counts[ycd.next()]++;
    c += 1000000000;
    ymo_print_uL_commas(c,20);
    cout << "    ";
    ymo_print_u64s(counts,10);
}
5:00 AM
Is that memset in C++ I see?
@GManNickG :) Gotta love quick and dirty code habits. :P
I will allow it this once!
Yet you seem to be fine with my macro abuse?
:P
Meh. :)
Also, the code doesn't actually "need" a nested loop. I just wanted to print out the progress every once in a while since it takes several hours to run.
5:04 AM
Yo guys, kind of a dumb question but... Is it generally pointless to pass private (or public) member variables of a class as parameters to a function that is in the same class?
so like:
class A {
public:
int Something(int &my_member_var); // passing the variable down below

private:
int my_member_var;
};
you wouldn't need to, each class method can already access all the members
Yup I thought so...
wow:
-6
Q: novice needs help

Michl HardtniggI'm not a programmer or computer person BUT I know I need your help. I'm a photographer in South Africa. I want to know if one can find (hopefully free) an application that collects email addresses of newspapers from the Internet into a database. My goal is to have all emails of newspapers world...

If you can't figure out how to spam on your own, it's time to search for a new career. — The Establishment 14 mins ago
user868935
5:21 AM
Hi everyone. Any know where I could get a good tutorial for using boost?
cpx
cpx
I know the one that I used a year ago en.highscore.de/cpp/boost
user868935
@cpx Thanks!
cpx
cpx
You'll find introductory examples for each library use in it.
5:49 AM
Did you have a question? If you just want us to do your homework, it's usually easiest to include your teacher/professor's email, so we can send the solution to him directly, and save you the trouble. — Jerry Coffin 1 min ago
77 flags and counting... awesome...
@Mysticial It's that damn Coffin guy's fault. If he hadn't made such a rude comment, I'm sure this fine <strike>l</strike>user would have gotten lots of excellent answers.
Aww, the flags are gone now. Was hoping for a screenshot at 100... :(
Wait... now I'm confused... are you referring to yourself? or...
@Mysticial Oh...um...no, it's not really me. It's that clone who keeps using my account... :-) Come to think of it, maybe that's why I can't remember half of what I do. Yeah, that must be it.
6:05 AM
I got confused because the message respond arrow was pointing to my 77 flags comment.
@Mysticial Oh, sorry 'bout that.
When you add an object to an STL container, is it by value or by reference? Like if I create a Foo on the heap, insert() it to an std::vector, then delete the Foo, is the Foo that is in std::vector still valid?
sorry if this question isn't clear
By value -- i.e., what goes in the container is a copy of what you pass, not the original object (though, of course, you can create a container of pointers, in which case you get a copy of the pointer, still pointing to the same actual object).
ok thank you
No problem.
6:15 AM
If you declare a container on the stack, will the stuff you put in it necessarily be on the stack as well?
Or is that up to the implementation of the container
The standard says nothing about stack or heap. But you can assume that any resizable container will put everything on the heap.
Wow, the entire standard?
or just regarding containers
I think it's the entire standard.
Like, even when the standard defines new and malloc
it makes no mention of the heap?
@newprogrammer why would it? It describes the properties of memory allocated with new
6:19 AM
They use the term "automatic storage" and ... I forgot what they use for dynamically allocated stuff...
@jalf idk lol, that's just surprising to me
@newprogrammer The question you are trying to ask is this: "when should I allocate stuff on the heap". The answer is "almost never. Let that be done internally by the classes that need it"
So in your vector question, if you create a Foo on the heap, you're doing it wrong
What if i need to make a lot of them
@newprogrammer How would the heap make any difference there?
If you need to make a lot of them, put them in a vector. That's what it's for
uhhhhh
ok
that makes sense
6:24 AM
std::vector<Foo> vec; for (int i = 0; 0 < lots; ++i) { Foo f; /*do what needs doing with the Foo object */ vec.push_back(f); }
vector on the stack, Foo object on the stack, Foo object copied into vector
i'm not really allocating a Foo on the heap
it just seemed like the best way to phrase the question
guess not =)
@Mysticial Well, technically it does talk about stack and heap. Specifically, std::stack and things like std::heapify. Not that they're really relevant. Dynamic allocation comes from "the free store"
well, a simpler way to put this rule of thumb is this: "don't write new/delete" (new is occasionally ok, if you immediately store the returned pointer into a smart pointer)
i use new and delete all the time though =(
@newprogrammer take this as an opportunity to learn then :)
6:27 AM
@JerryCoffin Ah... that was I wasn't aware of.
@newprogrammer Join Memory Mismanagers Anonymous. (BTW, how is it "anonymous", when the first thing you're supposed to do is tell everybody your name?)
@jalf do you know how you can access the iterator without having to do the verbos of the container type to get the iterator? eg.. std::vector<Foo>::iterator i =
Not that I'd know from experience -- I was a drunk, not an alcoholic. We didn't schedule our meetings... :-)
So what's worse: new / delete, or three-star programming?
Drives me a bit nutty having to constantly redeclare the same type over and over again
6:29 AM
i heard c++11's auto helps with that
@Chad Under C++03, almost anything like that I'd put into a template function, so the type was just T.
I admit to two-star programming in C. But I don't think I've ever had to go 2 stars in C++.
@newprogrammer yes, though i find it a bit odd that for a generic algorithem that you need to re-declare the container to access its iterator. Not to mention its end
@JerryCoffin Isn't that kind of cyclic loop, that to use stl more effectively you need to imbrace using template meta programming?
@Chad No. Templates, yes. Metaprogramming, no. I use templates a lot, but metaprogramming only rarely.
@JerryCoffin I originally thought so :)
Xeo
Xeo
6:32 AM
@Mysticial I'm sure you did in secret, but it was abstracted away by templates!
@JerryCoffin I love that functional thinking. Just stuff it in a new function and have the argument types deduced.
@Xeo Is that "functional thinking"? I always thought of it as "constructive laziness"!
Does hiding pointers behind typedefs still count towards the # of "stars"? I'm wondering if it's even possible to do dynamic 3D matrices in C without 3-star programming.
Or does the term "3-star programmer" only apply to C++.
@Mysticial Yeah, I'd say it still counts. If you could hide it completely, it would be one thing, but even when you use a typedef, the rest of the code ends up "aware" that it's dealing with a pointer (usually anyway).
Xeo
Xeo
@JerryCoffin Well, for me at least it seems kinda functional...ish
@Xeo Okay, I'm fine with that.
6:37 AM
scoped_ptr is fantastic
how have i not used this before
Xeo
Xeo
I kinda came to like functional style programming a lot
Especially since finding Boost.Range('s adaptors)
@Xeo Ranges are awfully handy, aren't they? Andre doesn't approve of Boost's idea of ranges though.
@Xeo I like being able to do functional programming a lot -- but the minute it's forced, it turns into a massive pain (i.e., "pure" functional languages cause me nothing but trouble).
Xeo
Xeo
I don't think you should solemly build on ranges. Iterators should still be the lowest level kinda thing, since ranges just don't make sense for a single element for example (to me, atleast). So, ranges as a higher-level abstraction over iterators (aka Boost style) hell yeah
Does having 3 levels of iterators and dereferencing them as ***iter count as 3-star programming? :P
Or is it worse?
Xeo
Xeo
I'd only think about banishing iterators if single-element ranges were as intuitive. Otherwise, it's just counter-productive imho
6:42 AM
@Xeo Yeah -- Andre thinks the whole idea of individual iterators should go, and there should only be ranges, but I'm not entirely convinced.
Pure languages are cool.
Xeo
Xeo
@Mysticial tripple indirection in a single statement? I don't think you ever need that, really.
The slides from Andre's talk on it, in case anybody cares:
Xeo
Xeo
double.. sure, if you're storing smart pointers
@Xeo I've definitely done that in C -- an array of arrays of strings...
Xeo
Xeo
6:44 AM
@JerryCoffin I really don't like the ranges he presents in those slides.
@JerryCoffin I thought we were talking C++ & iterators? :P
@JerryCoffin If it's the same slides I read a while ago. Seemed like it from a first glance, though
@Xeo Probably is.
As far as "three star programming" goes, try to figure out what this prints before you compile and run it:
#include<stdio.h>

char *c[] = { "ENTER", "NEW", "POINT", "FIRST" };
char **cp[] = { c+3, c+2, c+1, c };
char ***cpp = cp;

main()
{
printf("%s", **++cpp);
printf("%s ", *--*++cpp+3);
printf("%s", *cpp[-2]+3);
printf("%s\n", cpp[-1][-1]+1);
return 0;
}
2
ow... my eyes...
formatting fail :)
Xeo
Xeo
Geh, too lazy to deal with the pointer manipulation
@Mysticial There's no amount of formatting that can help in this case (except maybe formatting your hard drive to exorcise it).
@Xeo Think of them as "iterators" with ++ and -- operators.
@JerryCoffin I meant that it didn't one-box properly.
6:49 AM
that is more intresting
@Mysticial Probably not, but even if it had, it wouldn't help (much, anyway).
Xeo
Xeo
@JerryCoffin Slide 20, "some containers cannot be supported" ... "sentinel-terminated" erm, streams do that, non? ... "distributed storage" I can't think of a reason why they wouldn't. It would just be a forward range, though.
@Xeo Yeah -- like I said, I'm not entirely convinced.
@Chad the number of closed lines (e.g. 8 has 2, 9 has 1, 2 has 0) so the answer is 2.
Xeo
Xeo
6:51 AM
@classdaknok_t You could also just say the number of circles
@classdaknok_t number of circles in the numbers
Xeo
Xeo
Or circle-like thingies
@Xeo closed curves.
Why would a programmer do any better than someone with higher education?
Yeah but 0 has one of them and it's not a circle. Rather an ellipse.
Xeo
Xeo
6:53 AM
@JerryCoffin Thanks
What about pre-school child programmers with higher education?
2
@Mysticial Despite their education, most programmers retain at least a little creativity. Most of "education" concentrates on stamping that out.
@JerryCoffin If the text was not included in the question, I would've busted out my linear equation solver... That probably would've given me the answer in 20 min.
But since it mentions easy for pre-schoolers... I got the hint... but yes, it's hard to unlearn 23 years of school and think like a pre-schooler... :(
that was fun Chad :)

« first day (551 days earlier)      last day (4610 days later) »