Nick Coghlan wrote:
> Py3k's function overloading should fix this:
>
> @overloaded
> def sqrt(value):
> raise TypeError("Cannot take square root of %s" % type(value).__name__)
>
> @sqrt.overload
> def sqrt_float(value : float):
> return math.sqrt(value)
>
> @sqrt.overload
> def sqrt_complex(value : complex):
> return cmath.sqrt(value)
>
> @sqrt.overload
> def sqrt_decimal(value : decimal):
> return value.sqrt()
>
> # Similar overloads can be added for the types in gmpy and numpy.
So where would that sqrt function live? I hope you are not proposing it
becomes a builtin - I dearly wish there were fewer builtins, not more.
Regards,
Martin
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com