Re: Allow objects in define()

From: Date: Mon, 14 Jun 2021 23:36:35 +0000
Subject: Re: Allow objects in define()
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-114873@lists.php.net to get a copy of this message
On Mon, Jun 14, 2021 at 7:47 PM Larry Garfield <larry@garfieldtech.com>
wrote:

> On Mon, Jun 14, 2021, at 9:35 AM, Nikita Popov wrote:
> > Hi internals,
> >
> > With the introduction of enums, it's now possible for constants to hold
> > objects. However, this works only when using the const X = Y syntax,
> not
> > when using define('X', Y), which still excludes objects.
> >
> > I've submitted https://github.com/php/php-src/pull/7149 to
> > relax the
> > restriction. This means that define() would accept everything apart from
> > recursive arrays.
> >
> > An alternative here would be to allow define() to only accept enum
> objects
> > in particular, but not other objects. I would prefer not to do that, as
> > such a restriction would be rather arbitrary, now that the technical work
> > to support objects has been done. (PS: Please keep the difference between
> > mutability and interior mutability in mind.)
> >
> > Regards,
> > Nikita
>
> Sounds fine to me.  define() is runtime anyway so it should support
> runtime values.
>

Sounds sensible to me too. Good enhancement.


>
> --Larry Garfield
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
>
>


Thread (9 messages)

« previous php.internals (#114873) next »