Where is CASE?????

Phlip phlip_cpp at my-deja.com
Tue Feb 20 10:16:08 EST 2001


Proclaimed D-Man from the mountaintops:

> Why does it?  CASE is little more than a special if-else ladder for
> integral types only.  If you are simply trying to get a value, use a
> dictionary lookup instead.

If you are simply trying to run a jump table, use a dictionary where the 
stored values are functions. Modules written after the putative 'switch' 
statement could enrole their functions in it without changing its code.

Mr. Manners reminds the Original Gentle Poster that many things 
traditionally coded as 'switch' statements (typically those that repeat 
often in code) ought to go thru the refactor Replace Conditional with 
Polymorphism, per the book /Refactoring/.

-- 
  Phlip                          phlip_cpp at my-deja.com
============== http://phlip.webjump.com ==============
  --  It's a small Web, after all...  --



More information about the Python-list mailing list