Hi
On 6/30/24 18:08, Rob Landers wrote:
We can argue the semantics of input/output, but the point still stands that
return by reference is still more common than structured array, and even then,
those are usually much bigger things.
Happy to argue with you. I explained for each of the examples you
mentioned how it differs from the use-case solved by `bcdivmod()`.
To give some examples of functions that return a structured array and
that I believe to be reasonably similar (meaning: they destruct/parse
the input value instead of just providing some metadata like
opcache_get_status()):
- pathinfo()
- date_parse()
- getimagesize()
- openssl_x509_parse()
- password_get_info()
And for functions that return system information:
- opcache_get_status()
- sys_getloadavg()
- stat()
Please explain how their output arrays being “much bigger” makes a
difference to how the API is perceived by the user that wants to use it.
Functions I see where the result is returned by out parameters only,
without having a regular primary return value are (this also includes
some closely related functions in openssl and socket that I do not list
explicitly):
- getmxrr()
- openssl_csr_export()
- socket_getpeername()
And for all of those it would arguably a better API to just return the
value and throw an Exception on failure.
Best regards
Tim Düsterhus