[LUAU] Re: Python (Was Re: Hosef)

Tim Newsham newsham at lava.net
Wed Nov 23 09:35:03 PST 2005


>> 	for ( ; *s++ = *t++ ; ) 		;
>
>                   while (*s++ = *t++) {
>                           /* empty body */
>                     } ;.

I always found "continue" to be a lot more explicit in situations
like this:

      while(*s++ = *t++)
          continue;

the empty semi-colon being the least attractive alternative (did
he really mean to leave the body empty?  not to mention the greener
programmer will easily overlook the semicolon).

> In any case, both examples have the issues of the side-effects of the 
> assignment (being used for the test here).  The author of either example also 
> has to worry about the loop terminating (finding a null pointer).

No complaints about assignment in the loop test? :)
(Another sure way to confuse the younger C coder).

> For all but trivial copies like this memcpy() (aka bcopy()) is probably a 
> better "solution", though of course it won't terminate on a null pointer like 
> the above.

But strcpy() will :)

> Jim

Tim Newsham
http://www.lava.net/~newsham/



More information about the LUAU mailing list