switch

Carl Banks pavlovevidence at gmail.com
Wed Dec 9 22:00:59 EST 2009


On Dec 9, 5:02 pm, Asun Friere <afri... at yahoo.co.uk> wrote:
> On Dec 9, 7:08 pm, Carl Banks <pavlovevide... at gmail.com> wrote:
>
> > What if the object is a string you just read from a file?
>
> > How do you dispatch using polymorphism in that case?
>
> This would be a pertinent question, were I advocating that _all_
> switch statements should, or even can, be replaced with "dispatch
> using polymorphism."

Then why did you claim that a decent OO should never have a switch
statement then?  You argued that a decent language OO should never
have a switch statement because polymorphic dispatch is the right way
to handle it in OO languages, which implies that polymorphism can and
should take the place of any switch statement.


> What if, instead of reading strings from a file,

Why don't you answer my question first, then I'll entertain whatever
point you are trying to make with this example?


Carl Banks



More information about the Python-list mailing list