Re: Duff's device

From: Date: Fri, 15 Dec 2000 17:46:45 +0000
Subject: Re: Duff's device
References: 1  Groups: php.lang 
Request: Send a blank email to php-lang+get-100@lists.php.net to get a copy of this message
I'm not suprised that it doesn't work. I've seen this before, but never quite understood how the compiler handles the do..while loop. Logically, I understand how it works, but I'm not sure how the program finds the beginnning of the loop. Thanks. Peter > > Just wondering: > > as PHP syntax is heavily based on C syntax i was curious if it > would accept this code snippet: > > > > <?php > > $to=""; > $from="abcdefghijklmnopqrstuvwxyz"; > $count=12; > > $n = ($count + 7) / 8; > $i=0; > switch ($count % 8) > { > case 0: do { $to .= $from{$i++}; > case 7: $to .= $from{$i++}; > case 6: $to .= $from{$i++}; > case 5: $to .= $from{$i++}; > case 4: $to .= $from{$i++}; > case 3: $to .= $from{$i++}; > case 2: $to .= $from{$i++}; > case 1: $to .= $from{$i++}; > } while (--$n > 0); > } > > echo $to; > > ?> > > > > sure enugh it didn't although the C equvalent is indead legal > > -> > http://www.tuxedo.org/~esr/jargon/html/entry/Duff's-device.html > > ;) > > -- > Hartmut Holzgraefe hartmut@six.de http://www.six.de > +49-711-99091-77 > > -- > PHP Language Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-lang-unsubscribe@lists.php.net > For additional commands, e-mail: php-lang-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.lang (#100) next »