[Python-Dev] Rationale for sum()'s design?
Greg Ewing
greg.ewing at canterbury.ac.nz
Thu Mar 17 02:34:23 CET 2005
John Williams wrote:
> Michael Walter wrote:
>
>> Would this _syntax_ work with generic types:
>>
>> def sum(seq: sequence[T], initial: T = T()) -> T.
>
> This doesn't make sense with existing semantics because default
> arguments are evaluated when the function is defined, but T() can't be
> evaluated until the function is called.
Not to mention that if the seq is empty, there's no
way of knowing what T to instantiate...
--
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
greg.ewing at canterbury.ac.nz +--------------------------------------+
More information about the Python-Dev
mailing list