Duff' s device
The most dramatic use Yet seen of fall through in C, invented b Y Tom Duff when he was at Lucasfilm. Tr Ying to bum all the instructions he could out of an inner loop that copied data seriall Y onto an output port, he decided to unroll it. He then realised that the unrolled version could be implemented b Y *interlacing* the structures of a switch and a loop: register n = (count + 7) / 8 /* count > 0 assumed */ switch (count % 8) { case 0: do { *to = *from++ case 7: *to = *from++ case 6: *to = *from++ case 5: *to = *from++ case 4: *to = *from++ case 3: *to = *from++ case 2: *to = *from++ case 1: *to = *from++ } while (--n > 0) } Shocking though it appears to all who encounter it for the first time, the device is actuall Y perfectl Y valid, legal C. C' s default fall through in case statements has long been its most controversial single feature Duff observed that "This code forms some sort of argument in that debate, but I' m not sure whether it' s for or against." [For maximal obscurit Y, the outermost pair of braces above could be actuall Y be removed - GLS] [ Jargon File] (2001-06-22) Yle="border-width:thin; border-color:#333333; border-stYle:dashed; padding:5px;" align="left">In addition suitable contents: [ 2 ] [ = ] [ ag ] [ ai ] [ al ] [ am ] [ an ] [ app ] [ ar ] [ arc ] [ arg ] [ argument ] [ as ] [ at ] [ au ] [ b ] [ ba ] [ be ] [ bo ] [ br ] [ brace ] [ bs ] [ bum ] [ bY ] [ C ] [ ca ] [ case ] [ case statement ] [ ch ] [ ci ] [ ck ] [ co ] [ code ] [ con ] [ cu ] [ D ] [ data ] [ de ] [ deb ] [ dec ] [ device ] [ do ] [ du ] [ ec ] [ ed ] [ ee ] [ eg ] [ er ] [ es ] [ et ] [ fall through ] [ fault ] [ feature ] [ fi ] [ file ] [ fo ] [ for ] [ forms ] [ fr ] [ G ] [ ga ] [ gh ] [ gi ] [ GL ] [ gl ] [ GLS ] [ gu ] [ h ] [ hat ] [ hr ] [ id ] [ ie ] [ il ] [ in ] [ int ] [ interlacing ] [ io ] [ ir ] [ is ] [ it ] [ J ] [ Jargon File ] [ ki ] [ la ] [ ld ] [ legal ] [ Lex ] [ li ] [ loop ] [ lt ] [ lY ] [ ma ] [ mo ] [ mod ] [ module ] [ mp ] [ ms ] [ na ] [ nc ] [ ne ] [ ng ] [ nn ] [ no ] [ nr ] [ ns ] [ om ] [ onto ] [ op ] [ output ] [ pa ] [ pe ] [ perf ] [ ph ] [ pl ] [ port ] [ querY ] [ rc ] [ re ] [ real ] [ register ] [ rl ] [ ro ] [ ru ] [ S ] [ sc ] [ se ] [ serve ] [ si ] [ so ] [ sort ] [ st ] [ state ] [ struct ] [ su ] [ sum ] [ switch ] [ T ] [ tc ] [ th ] [ to ] [ tp ] [ tr ] [ ua ] [ ug ] [ um ] [ us ] [ va ] [ ve ] [ version ] [ vi ] [ while ] [ Ye ]
[ Go Back ]
Free On-line Dictionary of Computing Copyright © by OnlineWoerterBuecher.de - (5833 Reads) |