From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fc89c,97188312486d4578 X-Google-Attributes: gidfc89c,public X-Google-Thread: 109fba,baaf5f793d03d420 X-Google-Attributes: gid109fba,public X-Google-Thread: 1014db,6154de2e240de72a X-Google-Attributes: gid1014db,public X-Google-Thread: 103376,97188312486d4578 X-Google-Attributes: gid103376,public From: cjsonnack@mmm.com (Chris Sonnack) Subject: Re: What's the best language to start with? [was: Re: Should I learn C or Pascal?] Date: 1996/08/05 Message-ID: <4u5682$qgs@dawn.mmm.com>#1/1 X-Deja-AN: 172260596 references: <320433CE.6D5A@online.no> <4u1g29$hc0@solutions.solon.com> <01bb826a$b222f400$9bee6fce@timhome2> <4u3tt1$qub@solutions.solon.com> followup-to: comp.lang.c,comp.lang.c++,comp.unix.programmer,comp.lang.ada organization: 3M/IT/EIS (St.Paul,MN 55144) reply-to: cjsonnack@mmm.com (Chris Sonnack) newsgroups: comp.lang.c,comp.lang.c++,comp.unix.programmer,comp.lang.ada Date: 1996-08-05T00:00:00+00:00 List-Id: Peter Seebach (seebs@solutions.solon.com) wrote: >>> A lot of programmers used to habitually use a null pointer as a shortcut >>> for "" for string functions; you'd see >>> if (strcmp(s, 0)) >>> used like >>> if (strcmp(s, "")) >>> because it worked on some machines. >> >> This completely makes the point. Someone who knows assembly language >> would *never* make that mistake, because it would be so obviously >> wrong. > > An interesting theory. Not a theory. I've seen it personally. Because I know what "" really is under the hood, I know it has nothing in common with a NULL pointer. And I've seen a co-worker, a fellow professional who's been doing this for a number of years, make the above mistake. Not just once, but several times. > comp.sys.amiga.programmer, the assembly people would always talk about > how the first instruction in their programs was always > movel #0,0L > > A high-level programmer would never do that, because someone who has > learned only the abstract semantics would not think of a null pointer > as the address of any real memory. It isn't; it's *guaranteed* that > no object has a null pointer as its address. Yep. True. (Although, honestly, 90+% of all implementations define NULL along the lines of: (void*)0) But that doesn't really change the point that's being made: >> You cannot program in assembly and not understand a null >> pointer v.s. a pointer to a zeroed memory location. This is also true. The point is "" is a real object in memory, and any assembly programmer would know that. What the NULL pointer is doesn't matter here; the point is that "" ain't the NULL address. -- Chris Sonnack http://eishcq.mmm.com Engineering Information Services/Information Technology/3M, St.Paul, Minn ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ How's my programming? Call 1-800-DEV-NULL Opinions expressed herein are my own and may not represent those of my employer.