# [PATCH] Resubmitted for review

- Thread: https://externals.io/message/13274
- Original archive: https://news-web.php.net/php.internals/13274
- Started by Robert Silva on 2004-10-12T06:54:50+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #13274 — Robert Silva — 2004-10-12T06:54:50+00:00

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

This patch allows php extension authors to declare constants on internal
objects. This pretty much just duplicates the zend_declare_property_*
functions but for constants. Currently there is no way for C level class
authors to declare constants on their objects since the engine has to
allocate space for them.

Bob Silva

---

## #13292 — Andi Gutmans — 2004-10-12T21:43:11+00:00

URL: https://externals.io/message/13274#13292 · In reply to: #13274

We were discussing adding a per class (zend_class_entry *) callback for 
constants. It might make sense to allow that and if the callback is `NULL` 
then try the constant's hash in zend_class_entry.
That should solve all cases, right?

Andi

At 11:54 PM 10/11/2004 -0700, Robert Silva wrote:
>This patch allows php extension authors to declare constants on internal
>objects. This pretty much just duplicates the zend_declare_property_*
>functions but for constants. Currently there is no way for C level class
>authors to declare constants on their objects since the engine has to
>allocate space for them.
>
>Bob Silva

---

## #13295 — Marcus Boerger — 2004-10-12T22:34:11+00:00

URL: https://externals.io/message/13274#13295 · In reply to: #13292

Hello Andi,

Tuesday, October 12, 2004, 11:43:11 PM, you wrote:

> We were discussing adding a per class (zend_class_entry *) callback for 
> constants. It might make sense to allow that and if the callback is `NULL` 
> then try the constant's hash in zend_class_entry.
> That should solve all cases, right?

Andi still the patch is a good extension to the engine API and i think
we should add it. Why should every programmer that wants constants add
constant handlers just to add some basic constants? I see the handlers
only to allow soem special cases, maybe to have array consts or whatever.

marcus

---

## #13337 — Andi Gutmans — 2004-10-15T00:13:48+00:00

URL: https://externals.io/message/13274#13337 · In reply to: #13274

Hi Robert,

If I remember correctly, we came to the conclusion a while ago, that unless 
we make some big changes (which I'm not quite sure yet how far reaching 
they would be), then we could not malloc() constants. You would really need 
to emalloc()/efree() them on each request because the engine could connect 
to these malloced()'ed variables and all hell would break loose. Also we do 
a zval_update_constant() today in order to initialize constants with 
constants just before they are being used the first time.

What this basically means that you'd initialize and free these constants in 
RINIT()/RSHUTDOWN(). Not too sexy but looking at how much this is needed 
it's not too bad.

Andi

At 11:54 PM 10/11/2004 -0700, Robert Silva wrote:
>This patch allows php extension authors to declare constants on internal
>objects. This pretty much just duplicates the zend_declare_property_*
>functions but for constants. Currently there is no way for C level class
>authors to declare constants on their objects since the engine has to
>allocate space for them.
>
>Bob Silva
