Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124893 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 2FB401A00B7 for ; Mon, 12 Aug 2024 16:27:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1723480162; bh=OFPhhbFbfYROZTQXwQD3yHn2VcymlwwZ36tToRAGM5M=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=C8DYkK0CGCNPeITzlPAncvLfl+ucVJsXUE/YUL/VZYieIwMtygEVqG6tqlljZbIMu Is9rI42/QJlEeHHr/RcIimcnmy6ifvlzIQEiOA1dkWJGFA/2wTSb8MCqY4oGi/Nx0L 4C3LkKZKlqxXDRQaJQO3sKsT4MjNbmWbavnvnqWGTj5nQUoZQmEVg/S1eSQwNW7/L5 gb1oCV2ZORriPHdvcqcJu3SOb0D0qO78PuSJT4HGwsJeAgrSGWHgvHCidUmgpj9qeZ IpuxV9y4RAddGwcrpqNaGLcAfm7tuDDq6O2JxLhymdr6fSRzeRv2oR2erT7cBpEGUP 93yi/HQ44PIcQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1FB9618005B for ; Mon, 12 Aug 2024 16:29:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-vk1-f169.google.com (mail-vk1-f169.google.com [209.85.221.169]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 12 Aug 2024 16:29:21 +0000 (UTC) Received: by mail-vk1-f169.google.com with SMTP id 71dfb90a1353d-4f52c326501so1597647e0c.1 for ; Mon, 12 Aug 2024 09:27:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723480056; x=1724084856; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=LHND9XhA3mbY8KpxlJHzD9slLzbntL8wgu25t8oH2+o=; b=DHigTEgRwKMQi72uvk3ETyvGcn/U1bdJ1BnU77jFdHaTJqNfqGln926kt11HMJPE3s p8FAfQzjzM8OyMHFKldszpTyLbxGOd4Uul33dgruFHhX/rpU+unxfqxNXp07KFR1hEN+ Hc0UiSa/c3AtvH9Xz2lKE6hMKP22L9nuZGJ6TQ0PIlpRGpqyDcpyLWYTw0GvifNC8HUf T4EZ2d7M85Da4Qu0eK8MilJPx/dpoRe6ZQKw1yghSZu+ojJSvXOT85DR5Mw+ZKhLGL36 CZsClgwF9Zo7YqEUlEzeKcNHTrQpqkM1jR9Q97ywUeqv3w7rIUe6wATPA2Djmf9KKh/G KpeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723480056; x=1724084856; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=LHND9XhA3mbY8KpxlJHzD9slLzbntL8wgu25t8oH2+o=; b=KMdzszHDxjf4mHoV67nHNYf0/1NUA993svAfrT/RTA8N/c+7LMOFTTKdUXQffdqHG0 6wE8W4diScG9IuqrE6DzMOb7hIQhwOudE2WYV0Lgn4DYQ9p1EHvLvAVw0N7gODGlPhkF x4bsoLKPhNzxeU5iD44c9f27QmWGk/sLhqfwiOKc+SYgNAcoIbVh4epjq4vUNEd8fBSW jcTHgZi+pcw0Y/rORQIUNnRzYzOeIqIpAx7r92hM67N+4iZ3gBl4UnKX7OSXibmUSJpg pO7v9NyzGBawu3CLbg6PfD8Yl41qVk16Envi8bKBRTPiAASc6T/hQaK1a67AeAJDrPFN GrgA== X-Forwarded-Encrypted: i=1; AJvYcCV7wyV43N50mGv6HxW2zWJPlcVPADRmY97jhDy6Tc7WM/ganyBSBgyNZyI1T8s3Z+Ur1zjMn27oaXIhBcnjQ7oxUfFT6cmA0w== X-Gm-Message-State: AOJu0YyBeJxknbY8S9CEfhWkKNfDth+44OMJZ+eTb7f6hTaax5N0RYOq PI0y81tVxk+VyRzWb4LIylqp80f8QaxwG8oM1ea0cTM2ozs4Qk1U02a3yQiqC+DPuhBUoLEDb9m sW6RMJaGXRPFEzl3jyihDC+8Rz5g= X-Google-Smtp-Source: AGHT+IFWVK+CqZjPvw2TlR4I+cfGVgyJNrLjlJAjgVIvSceEv3Cxzx4GFfkMmpeldOJzRxmwPDM3hdvGnTQ5iVXMsH8= X-Received: by 2002:a05:6122:d99:b0:4f5:d98:5ef2 with SMTP id 71dfb90a1353d-4fabeef14fcmr1265104e0c.4.1723480055802; Mon, 12 Aug 2024 09:27:35 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <3F5C5B7F-6EE5-437D-9E4A-4C86EC103E7A@getmailspring.com> In-Reply-To: <3F5C5B7F-6EE5-437D-9E4A-4C86EC103E7A@getmailspring.com> Date: Mon, 12 Aug 2024 10:27:25 -0600 Message-ID: Subject: Re: [PHP-DEV] [DISCUSSION] C++ Enhancements in Zend API To: John Coggeshall Cc: Levi Morrison , PHP internals Content-Type: multipart/alternative; boundary="00000000000080f91f061f7ef8a5" From: lnearwaju@gmail.com (Lanre) --00000000000080f91f061f7ef8a5 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Aug 12, 2024 at 9:58=E2=80=AFAM John Coggeshall wrote: > > > I=E2=80=99m considering adding some C++ enhancements to the Zend API. > > > I would definitely like to see an RFC for this if it was to be considered= . > To me, adding a whole new way of doing things internally without complete= ly > removing the old way is just asking for a more brittle, potentially less > secure, and harder to maintain codebase. The win of making it easier / > "nicer" on a subset of developers who might prefer a C++ interface isn't > anywhere near worth the risk IMO. > You aren't making any sense. Why would we remove the old way? Or why should that be a prerequisite to improving the current API? How are functions that simply proxy the C API inherently 'more brittle, potentially less secure, and harder to maintain'? You haven't even seen the code in question? ```cxx TVal(const zval *other) : TVal() { ZVAL_COPY(this, other); } TVal(zend_long value) : TVal() { ZVAL_LONG(this, value); } TVal(int value) : TVal() { ZVAL_LONG(this, value); } TVal(size_t value) : TVal() { ZVAL_LONG(this, value); } TVal(bool value) : TVal() { ZVAL_BOOL(this, value); } TVal(std::string_view value) : TVal() { ZVAL_STRINGL(this, value.data(), value.size()); } TVal(double value) : TVal() { ZVAL_DOUBLE(this, value); } TVal(const char *value) : TVal() { ZVAL_STRING(this, value); } TVal(const std::string &value) : TVal() { ZVAL_STRINGL(this, value.c_str(), value.size()); } bool IsNull() const { return Z_TYPE_P(this) =3D=3D IS_NULL; } bool IsTrue() const { return Z_TYPE_P(this) =3D=3D IS_TRUE; } bool IsFalse() const { return Z_TYPE_P(this) =3D=3D IS_FALSE; } bool IsBool() const { return Z_TYPE_P(this) =3D=3D IS_TRUE || Z_TYPE_P(this) =3D=3D IS_FALSE; } bool IsLong() const { return Z_TYPE_P(this) =3D=3D IS_LONG; } bool IsDouble() const { return Z_TYPE_P(this) =3D=3D IS_DOUBLE; } bool IsString() const { return Z_TYPE_P(this) =3D=3D IS_STRING; } bool IsArray() const { return Z_TYPE_P(this) =3D=3D IS_ARRAY; } bool IsObject() const { return Z_TYPE_P(this) =3D=3D IS_OBJECT; } bool IsInstanceOf(zend_class_entry *ce) const { return Z_TYPE_P(this) =3D=3D IS_OBJECT && (ce =3D=3D Z_OBJCE_P(this= ) || instanceof_function(Z_OBJCE_P(this), ce)); } bool IsCallable() const { return zend_is_callable((zval *) this, 0, nullptr); } bool IsResource() const { return Z_TYPE_P(this) =3D=3D IS_RESOURCE; } bool IsReference() const { return Z_ISREF_P(this); } ``` The above is a snippet from my current implementation, so please elaborate on which part of that is so crazy to you. Cheers, Lanre. --00000000000080f91f061f7ef8a5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Mon, Aug 12, 2024 at 9:58=E2=80=AF= AM John Coggeshall <john@coggesha= ll.org> wrote:

> I=E2=80=99m considering adding some C+= + enhancements to the Zend API.

I would de= finitely like to see an RFC for this if it was to be considered. To me, add= ing a whole new way of doing things internally without completely removing = the old way is just asking for a more brittle, potentially less secure, and= harder to maintain codebase. The win of making it easier / "nicer&quo= t; on a subset of developers who might prefer a C++ interface isn't any= where near worth the risk IMO.

You ar= en't making any sense. Why would we remove the old way? Or why should t= hat be a prerequisite to improving the current API? How are functions that = simply proxy the C API inherently 'more brittle, potentially less secur= e, and harder to maintain'? You haven't even seen the code in quest= ion?

```cxx
=C2=A0 =C2=A0 TVal(const zva= l *other) : TVal() { ZVAL_COPY(this, other); }
=C2=A0 =C2=A0 TVal(zend_l= ong value) : TVal() { ZVAL_LONG(this, value); }
=C2=A0 =C2=A0 TVal(int v= alue) : TVal() { ZVAL_LONG(this, value); }
=C2=A0 =C2=A0 TVal(size_t val= ue) : TVal() { ZVAL_LONG(this, value); }
=C2=A0 =C2=A0 TVal(bool value) = : TVal() { ZVAL_BOOL(this, value); }
=C2=A0 =C2=A0 TVal(std::string_view= value) : TVal() { ZVAL_STRINGL(this, value.data(), value.size()); }
=C2= =A0 =C2=A0 TVal(double value) : TVal() { ZVAL_DOUBLE(this, value); }
=C2= =A0 =C2=A0 TVal(const char *value) : TVal() { ZVAL_STRING(this, value); }=C2=A0 =C2=A0 TVal(const std::string &value) : TVal() { ZVAL_STRINGL(= this, value.c_str(), value.size()); }
=C2=A0 =C2=A0 bool IsNull() const = { return Z_TYPE_P(this) =3D=3D IS_NULL; }
=C2=A0 =C2=A0 bool IsTrue() co= nst { return Z_TYPE_P(this) =3D=3D IS_TRUE; }
=C2=A0 =C2=A0 bool IsFalse= () const { return Z_TYPE_P(this) =3D=3D IS_FALSE; }
=C2=A0 =C2=A0 bool I= sBool() const { return Z_TYPE_P(this) =3D=3D IS_TRUE || Z_TYPE_P(this) =3D= =3D IS_FALSE; }
=C2=A0 =C2=A0 bool IsLong() const { return Z_TYPE_P(this= ) =3D=3D IS_LONG; }
=C2=A0 =C2=A0 bool IsDouble() const { return Z_TYPE_= P(this) =3D=3D IS_DOUBLE; }
=C2=A0 =C2=A0 bool IsString() const { return= Z_TYPE_P(this) =3D=3D IS_STRING; }
=C2=A0 =C2=A0 bool IsArray() const {= return Z_TYPE_P(this) =3D=3D IS_ARRAY; }
=C2=A0 =C2=A0 bool IsObject() = const { return Z_TYPE_P(this) =3D=3D IS_OBJECT; }
=C2=A0 =C2=A0 bool IsI= nstanceOf(zend_class_entry *ce) const {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 retu= rn Z_TYPE_P(this) =3D=3D IS_OBJECT && (ce =3D=3D Z_OBJCE_P(this) ||= instanceof_function(Z_OBJCE_P(this), ce));
=C2=A0 =C2=A0 }
=C2=A0 = =C2=A0 bool IsCallable() const { return zend_is_callable((zval *) this, 0, = nullptr); }
=C2=A0 =C2=A0 bool IsResource() const { return Z_TYPE_P(this= ) =3D=3D IS_RESOURCE; }
=C2=A0 =C2=A0 bool IsReference() const { return = Z_ISREF_P(this); }
```

The above is = a snippet from my current implementation, so please elaborate on which part= of that is so crazy to you.

Cheers,
Lanre.

--00000000000080f91f061f7ef8a5--