Re: Optional Type Hinting

[email protected] (Dmitry Stogov)
Newsgroups php.internals
Message-ID <CA+9eiLur8HwFW1DF7Ok=-QmgPRB4RiYY2q6aB-UFgdWerb3HEw@mail.gmail.com>
The patch looks good and seems to contain the necessary opcache changes.

I'm not sure if you really need zend_return_hint.used and
zend_return_hint.class_name_type (may be I just didn't analyze the patch
deep enough).

You may support "self" by setting  zend_return_hint.class_name =
GC(actrive_class_entry)->name.
If return type hinting is unused then zend_function. return_hint should be
NULL

In PHP7 it may make sense to embed fields of zend_return_hint (zend_string
return_class_name and zend_uchar return_type) directly into zend_function.
It may keep the same memory usage for cases without return type hinting and
decrease it with return type hinting.

Thanks. Dmitry.


On Tue, Aug 19, 2014 at 8:23 AM, Levi Morrison <[email protected]>
wrote:

> On Mon, Aug 18, 2014 at 1:43 PM, Dmitry Stogov <[email protected]> wrote:
> > Hi Levi,
> >
> > The implementation is really not a problem. It must be quite simple and I
> > may take care about it.
> > The problem that we can't come to agreement on scalar type hinting for
> years
> > :(
> >
> > Thanks. Dmitry.
> >
> >
> > On Mon, Aug 18, 2014 at 9:57 PM, Levi Morrison <[email protected]>
> > wrote:
> >>
> >> On Mon, Aug 18, 2014 at 8:21 AM, Dmitry Stogov <[email protected]> wrote:
> >> > I see your point. For me they just don't have a lot of sense without
> >> > each
> >> > other.
> >>
> >> I am the author of two of those RFCs. I've worked with several members
> >> of the HHVM team so that any inconsistencies are planned and recorded
> >> (or will be; I know of one inconsistency in return types that is not
> >> currently recorded).
> >>
> >> I also am definitely not in favor of merging them, for the reasons
> >> Andrea outlined.
> >>
> >> Also, Dmitry, if you have interest in working on the implementations
> >> for these RFCs I'm sure Joe would appreciate the help (I know I
> >> would).
>
> Joe was able to get it mostly completed in a really short period of
> time, but there is some issue going on with opcache. I have forgotten
> the details now, but I think it had to deal with the fact that the
> types need to have delayed binding. Joe or Anthony, can you maybe give
> more information here?
>
> Additionally, the implementation was built off of master because it
> was created before PHPNG; I think I probably want to target PHP 7
> instead of 5.7 (again, PHP 7 was only being dreamed of then) so it
> would need rebased at least. Here's the work by Joe and Anthony:
> https://github.com/krakjoe/php-src/compare/returntypehinting
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.