home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.arch      Apparently more than just beeps & boops      131,241 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 131,085 of 131,241   
   George Neuner to jm@bourguet.org   
   Re: PDP-11 history, was Variable-length    
   14 Feb 26 17:58:00   
   
   From: gneuner2@comcast.net   
      
   On Sat, 14 Feb 2026 21:04:05 +0100, jm  wrote:   
      
   >George Neuner  writes:   
   >   
   >> On Wed, 11 Feb 2026 22:11:09 GMT, MitchAlsup   
   >>  wrote:   
   >>   
   >>   
   >>>40 years ago, Duff's device was considered a reasonable way to improve   
   >>>performance. It is now considered a means to take over applications   
   >>>and machines (i.e., a virus).   
   >>   
   >> I don't know that it ever really improved performance, but it still is   
   >> useful.  I use the switch() form for backing out of situations having   
   >> complicated setup where processing isn't possible unless all the setup   
   >> steps succeed.   
   >>   
   >> I keep track of how many setup steps successfully complete, and then,   
   >> whatever the exit situation, I jump into a Duff switch that tears it   
   >> all down in reverse order of the setup.   
   >   
   >This seems missing an important aspect of Duff switch: the use of the   
   >possibility to put case labels inside control structure. Duff's device use   
   >a while starting before the first label, but you can do other strange   
   >things like jumping into an if:   
   >   
   >    switch(i) {   
   >        case 1:   
   >            if (j == 3) {   
   >                case 2:   
   >                    printf("i == 2 || (i == 1 && j == 3)\n");   
   >            }   
   >    }   
   >   
   >or is you tears down complex enough to use such things?   
   >   
   >Yours,   
      
   I've never had to do anything like your example.  I realize that it   
   would work, but in fact I've actually never seen anything like that   
   done in real life.   
      
   For me, the utility of Duff's switch is that it provides multiple   
   entry points into ... what arguably could be considered a single block   
   of related code.   
      
   Of course, C permits any case in a switch to fall through. What makes   
   a particular case run a "Duff" (to me) is that the run includes at   
   least 2 cases which lead to separate[*] code, and every case in the   
   run falls through except the last one which exits the switch.   
      
   [*] separate. not necessarily different or unique.   
      
   I try not to put multiple "Duffs" in the same switch. I have had   
   occasion to do it, but only very rarely.   
      
      
   Certainly Duffs can do more than I use them for. I use them only for   
   what I need.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca