source code size metric: Python and modern C++

David Abrahams dave at boost-consulting.com
Sat Dec 7 09:00:36 EST 2002


Laura Creighton <lac at strakt.com> writes:

> David Abrahams
>
> <snip>
>
>> Otherwise, people will keep doing what they do today, which is either:
>> 
>> 1. Just specify that the function requires some concrete type, e.g. a
>>    list or tuple. At least its possible to give clients a clear
>>    specification of what's required of them.
>> 
>> 2. Write that it accepts any "sequence", and leave the client to read
>>    the source or hope they chose the right set of sequencey operations
>>    to implement.
>> 
>> Neither of thse leaves much hope for robust generic programming in
>> Python.
>
> What you are proposing is to make another type, so that people can know
> what is required of them, when they are asked for that particular
> type.

Yes, if we're using the broad definition of type.

> This will cause trouble for those of us who are already using 'sequence'
> to mean some subset or superset of whatever you come up with.  

How?

1. I said you could use the word "tartemption" for all I care

2. Your word 'sequence', unless you've already nailed down that
   "subset or superset of whatever I come up with", is meaningless
   anyway. So I don't mind "breaking backward compatibility" with it.

And, BTW, I never proposed to impose _my_ personal view of
sequence-ness on the world. I do think we should have a common
definition of what "sequence" means (with additional shades like
"mutable sequence" of course).

> Our problem of knowing whether we can use object X in protocol Y
> remains, we will just have one fewer word to discribe our objects
> with.

I don't really mind removing a word with no real descriptive power
from your available vocabulary <wink>

> My experience is that a lot of protocols that  'expect a sequence' want 
> 'any sliceable object' and that is all.

Oh, that's a new one on me! It's easy enough to make a sliceable
object for which

    print x[0]
        
doesn't work. I would have thought that would be an arbiter of
sequence-ness!

> What I want is an arbitrary way, in the language or in an IDE, to ask
> 'can I use this object here' and why not if I cannot.  

...if you mean some arbitrary _programmatic_ way, I think you'd better
forget it. No amount of introspection is going to tell you whether the
object satisfies the semantic requirements, in the general case.

> PEP 246, Object Adaption http://www.python.org/peps/pep-0246.html
> suggests one way we might do this.

You're not afraid someone will define the "Sequence" protocol and
reserve the meaning?

-- 
                       David Abrahams
   dave at boost-consulting.com * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution



More information about the Python-list mailing list