On Sat, 5 Dec 2020, 15:43 Larry Garfield, <la...@garfieldtech.com> wrote:

> On Sat, Dec 5, 2020, at 3:26 AM, Pierre R. wrote:
> > Le 05/12/2020 à 00:24, Larry Garfield a écrit :
> > > Greetings, denizens of Internals!
> > >
> > > Ilija Tovilo and I have been working for the last few months on adding
> support for enumerations and algebraic data types to PHP.  This is a
> not-small task, so we've broken it up into several stages.  The first
> stage, unit enumerations, are just about ready for public review and
> discussion.
> > >
> > > The overarching plan (for context, NOT the thing to comment on right
> now) is here: https://wiki.php.net/rfc/adts
> > >
> > > The first step, for unit enumerations, is here:
> > >
> > > https://wiki.php.net/rfc/enumerations
> > >
> > > There's still a few bits we're sorting out and the implementation is
> mostly done, but not 100% complete.  Still, it's far enough along to start
> a discussion on and get broader feedback on the outstanding nits.
> > >
> > > I should note that while the design has been collaborative, credit for
> the implementation goes entirely to Ilija.  Blame for any typos in the RFC
> itself go entirely to me.
> > >
> > > *dons flame-retardant suit*
> > >
> > Another question, about match() behavior:
> >
> >  > This usage requires no modification of |match|. It is a natural
> > implication of the current functionality.
> >
> > May be this could be the time to have a "strict match", using enums, we
> > can "statically" guess if branches are missing (of course, whenever you
> > use default it valid to miss branches) - one thing I'd love is PHP to
> > throw a fatal error when compiling a match expression whose missing
> > branches, and not wait until runtime to fail.
>
> I think that would make a great follow-up, but it's out of scope for now.
> Having match statically know what the available types are when the variable
> type isn't yet known (because it's in another file) is... I don't know how
> to do that.  That's a broad problem across PHP, frankly.  If we can figure
> out a way to do so, I'd support adding it in the future.  (I can't speak
> for Ilija, but I suspect he would be on board as well.)
>

Static analysis can (should?) be taken care of by any of the tools
available for PHP. Wouldn't it be a waste of effort to try to include it in
the runtime parser as well?

>

Reply via email to