Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Masklinn <masklinn-wgwPHP1t4nvk1uMJSBkQmQ <at> public.gmane.org>
Subject: Re: __iter__ implies __contains__?
Newsgroups: gmane.comp.python.ideas
Date: Sunday 2nd October 2011 11:21:35 UTC (over 5 years ago)
On 2011-10-02, at 03:01 , Nick Coghlan wrote:

> On Sat, Oct 1, 2011 at 4:24 PM, Chris Rebert
 wrote:
>> Requiring the explicit marking of a class as a sequence by inheriting
>> from the Sequence ABC in order to get such default behavior "for free"
>> seems quite reasonable. And having containment defined by default on
>> potentially-infinite iterators seems unwise. +1 on the suggested
>> removals.
> 
> -1 to any removals - fallback protocols are the heart of duck-typing
I very much disagree with this assertion. In fact I'd make the opposite
one: fallback protocols are a perversion of duck-typing and only serve
to make it less reliable and less predictable.

In keeping with ducks, you were looking for one, didn't find anything
which quacked or looked like a duck. The fallback protocol kicks in,
you get something with feathers which you found near water and went
"good enough". Now you drop it from 10000m because you're looking into
the efficiency of a duck's flight starting airborne, and observe your
quite dismayed penguin barreling towards the ground.

A few seconds later, you find yourself not with additional experimental
data but with a small indentation in the earth and a big mess all over
it.
 
CD: 2ms