# [DISCUSSION] C++ Enhancements in Zend API

- Thread: https://externals.io/message/124876
- Original archive: https://news-web.php.net/php.internals/124876
- Started by Lanre on 2024-08-11T21:54:07+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #124876 — Lanre — 2024-08-11T21:54:07+00:00

URL: https://externals.io/message/124876#124876

Hello,

I’m considering adding some C++ enhancements to the Zend API. These changes
would be encapsulated within `#ifdef __cplusplus` guards, so they wouldn’t
interfere with the existing C implementation. The primary goal is to
provide a nicer interface for extensions while maintaining compatibility
with C.

Key points:
- **Struct-based Approach:** Everything will still use structs—no classes
or non-public/non-static members.
- **Isolation:** Any enhancements that can be isolated from the C
implementation will be, and they will reside in a common `zend_api_cxx`
header file.
- **Proposed Enhancements:**
  - Constructors and destructors, along with comparison operator overloads
for `zval`.
  - Constructor overloads for common `zval` initializations.
  - Member methods for common `zval` operations.

I’m happy to implement and maintain these changes. Since this doesn’t
affect userland, do you think an RFC is necessary?

Also, if anyone has suggestions or ideas for this C++ API, I’d love to hear
them.

Cheers,
Lanre
