Comments on: Brief Intro to Pointers http://tleaves.com/2004/03/03/brief-intro-to-pointers/ Creativity x Technology Sat, 17 Mar 2012 05:09:58 +0000 hourly 1 http://wordpress.org/?v=3.3.1 By: peterb http://tleaves.com/2004/03/03/brief-intro-to-pointers/comment-page-1/#comment-150 peterb Fri, 10 Jun 2005 23:55:52 +0000 http://tleaves.com/?p=41#comment-150 Ouch! Nice catch. I've corrected the downloadable version. Thanks. Ouch! Nice catch. I’ve corrected the downloadable version. Thanks.

]]>
By: Anonymous http://tleaves.com/2004/03/03/brief-intro-to-pointers/comment-page-1/#comment-149 Anonymous Fri, 10 Jun 2005 22:58:19 +0000 http://tleaves.com/?p=41#comment-149 Good article. One issue though, the first code sample in the "But Why" section contains an error. The example in the article is correct, but the download version repeats val_incr in the print statement for the ref_incr function (See below). Took some head scratching to figure out... void val_incr(int counter) { printf("val_incr: start, counter is %d\n", counter); counter++; printf("val_incr: exit, counter is %d\n", counter); } void ref_incr(int *counter) { printf("val_incr: start, counter is %d\n", *counter); (*counter)++; printf("val_incr: exit, counter is %d\n", *counter); } Good article. One issue though, the first code sample in the “But Why” section contains an error. The example in the article is correct, but the download version repeats val_incr in the print statement for the ref_incr function (See below). Took some head scratching to figure out…

void val_incr(int counter) {

printf(“val_incr: start, counter is %d\n”, counter);

counter++;

printf(“val_incr: exit, counter is %d\n”, counter);

}

void ref_incr(int *counter) {

printf(“val_incr: start, counter is %d\n”, *counter);

(*counter)++;

printf(“val_incr: exit, counter is %d\n”, *counter);

}

]]>
By: Faisal N. Jawdat http://tleaves.com/2004/03/03/brief-intro-to-pointers/comment-page-1/#comment-148 Faisal N. Jawdat Fri, 05 Mar 2004 02:30:15 +0000 http://tleaves.com/?p=41#comment-148 I'd avoid the problem of teaching people addressing modes by just picking one form of assembler and sticking with it, probably on a "not real" processor. If you're teaching people direct and dangerous memory management, you might as well admit you're playing towers of hanoi on a grand scale instead of trying to pretend you're using a high level language. I’d avoid the problem of teaching people addressing modes by just picking one form of assembler and sticking with it, probably on a “not real” processor. If you’re teaching people direct and dangerous memory management, you might as well admit you’re playing towers of hanoi on a grand scale instead of trying to pretend you’re using a high level language.

]]>
By: PZ Myers http://tleaves.com/2004/03/03/brief-intro-to-pointers/comment-page-1/#comment-147 PZ Myers Thu, 04 Mar 2004 20:13:36 +0000 http://tleaves.com/?p=41#comment-147 Yeah, but when you start by learning assembler (like I did), you can't avoid learning the power of pointers, and all those addressing modes do weird things to your head that turn out to be fairly useful when programming. The last three universities at which I worked all started their students with Scheme. I have no idea why. Yeah, but when you start by learning assembler (like I did), you can’t avoid learning the power of pointers, and all those addressing modes do weird things to your head that turn out to be fairly useful when programming.

The last three universities at which I worked all started their students with Scheme. I have no idea why.

]]>
By: John Prevost http://tleaves.com/2004/03/03/brief-intro-to-pointers/comment-page-1/#comment-146 John Prevost Thu, 04 Mar 2004 15:19:14 +0000 http://tleaves.com/?p=41#comment-146 Modula-2? Wow. When I took the course, it was Common LISP. The next year, I think I heard it was SML (and people wanted to kill), and then switched up to Java shortly after that. Modula-2? Wow. When I took the course, it was Common LISP. The next year, I think I heard it was SML (and people wanted to kill), and then switched up to Java shortly after that.

]]>
By: peterb http://tleaves.com/2004/03/03/brief-intro-to-pointers/comment-page-1/#comment-145 peterb Thu, 04 Mar 2004 12:44:13 +0000 http://tleaves.com/?p=41#comment-145 Yeah, it's pretty clear that the C syntax for pointers is pretty horrible. I was with you in your suggestions until you said "...and assembler," because then you end up teaching the students 36 different CPU-specific addressing modes, which is the same thing as teaching them C's pointer syntax except now they have 36 different ways to blow their own feet off, instead of just 2. I'm pretty sure most Universities nowadays don't start with C, anyway, although I can't be sure, not being a student. I heard that the data structures and algorithms course at CMU, which used to be taught in modula-2 (kill me) is now taught in java, which makes sense to me. Yeah, it’s pretty clear that the C syntax for pointers is pretty horrible. I was with you in your suggestions until you said “…and assembler,” because then you end up teaching the students 36 different CPU-specific addressing modes, which is the same thing as teaching them C’s pointer syntax except now they have 36 different ways to blow their own feet off, instead of just 2.

I’m pretty sure most Universities nowadays don’t start with C, anyway, although I can’t be sure, not being a student. I heard that the data structures and algorithms course at CMU, which used to be taught in modula-2 (kill me) is now taught in java, which makes sense to me.

]]>
By: Faisal N. Jawdat http://tleaves.com/2004/03/03/brief-intro-to-pointers/comment-page-1/#comment-144 Faisal N. Jawdat Thu, 04 Mar 2004 12:24:49 +0000 http://tleaves.com/?p=41#comment-144 The issue with pointers isn't pointers, it's C. All programming languages have pointers of some sort (OK, all programming languages anybody uses for anything these days). But C delivers pointers in a format carefully optimized for blowing your foot off. I'm starting to think that CS should be taught with LISP and asssembler, graduating to something with managed memory, and that C style memory management should be a 300 or 400 level course rather than basic instruction. Either that or just force feed people the Boehm collector until they're old enough to know better. Meanwhile, back in the real world, I hear Python's nice. The issue with pointers isn’t pointers, it’s C. All programming languages have pointers of some sort (OK, all programming languages anybody uses for anything these days). But C delivers pointers in a format carefully optimized for blowing your foot off. I’m starting to think that CS should be taught with LISP and asssembler, graduating to something with managed memory, and that C style memory management should be a 300 or 400 level course rather than basic instruction. Either that or just force feed people the Boehm collector until they’re old enough to know better. Meanwhile, back in the real world, I hear Python’s nice.

]]>