[Python-3000] Lazy strings (was Re: Py3k release schedule worries)
Guido van Rossum
guido at python.org
Fri Jan 12 22:54:19 CET 2007
On 1/12/07, Larry Hastings <larry at hastings.org> wrote:
> Guido van Rossum wrote:
> Changing the API is the only reasonable solution amongst all the options
> I've seen. I defer to you. Perhaps another approach will surface; in the
> meantime I'll start on the API change.
>
> You suggested changing the name as a reminder of the semantics change. Are
> you interested in a structural change too? My personal aesthetic for APIs
> is to return success/failure separately from output parameters. So I
> propose something this:
> #define PyUnicode_VALUE(self, p, len)
> which would return nonzero on success and zero on failure. If it fails, p
> and len would be unchanged.
I like having a functionm (not macro) that returns pointer and length
through output variables. Yould call it as PyUnicode_Value(self, &p,
&len).
I don't like having a separate 'success' return value; in that case,
you could just set p to NULL and len to -1. Or if you like shortcuts,
you could make p the return value and len an output parameter, or vice
versa.
Experiment, see what results in the cleanest code in typical usage.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list