🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.atari.st
Article #37288

Re: A Lesson Learned

#37288
From: Scott Evernden
Date: Tue, 21 Mar 1989 21:50
29 lines
1554 bytes
In article <8903202254.AA00303@icase.edu> csrobe@ICASE.EDU (Charles S. [Chip] Roberson) writes:
>Greetings fellow psycho-programmers!  Well, I just learned a lesson today

>	fprintf( stderr, isprint(*cp)? "[%c]":"[%02x]", *cp++ );
>}
>--------------------------------------------------------------------------
>
>MWC passes parameters in reverse order.  That means that the "*cp++"
>gets evaluated BEFORE the "isprint(*cp)..." stuff. 

   Reverse compared to to what?  There is no defined "order" for arguments
   to be evaluated or pushed onto the stack (assuming you're using a stack,
   which you shouldn't assume!).

>The moral of this story?  Well, as my Theory of Prog. Lang prof would
>say, "That's just another insecurity of C!";

>... So much for portability,

   C is quite portable if you don't try to do cute things like the above
   which are defined to be non-portable.  This isn't a "gotcha", but
   something you simply need to learn.  What would you expect from, say:

	*ptr++ = ptr[5] + 2;

   Well, you'd be screwing yourself if you wrote this code, for the
   same reasons.  There are plenty of similar examples.

-scott
Technical Details
Message-ID: <930@applix.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ulowell!m2c!applix!scott
References: <8903202254.AA00303@icase.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ulowell!m2c!applix!scott
From: scott@applix.UUCP (Scott Evernden)
Newsgroups: comp.sys.atari.st
Subject: Re: A Lesson Learned
Message-ID: <930@applix.UUCP>
Date: 21 Mar 89 21:50:28 GMT
References: <8903202254.AA00303@icase.edu>
Reply-To: scott@applix.UUCP (Scott Evernden)
Organization: APPLiX Inc., Westboro MA
Lines: 29