PHP Internals News: Episode 103: Disjunctive Normal Form (DNF) Types PHP Internals News

    • Tecnologia

PHP Internals News: Episode 103: Disjunctive Normal Form (DNF) Types


London, UK

Friday, June 24th 2022, 09:07 BST



In this episode of "PHP Internals News" I talk with George Peter Banyard (Website, Twitter, GitHub, GitLab) about the "Disjunctive Normal Form Types" RFC that he has proposed with Larry Garfield.

The RSS feed for this podcast is https://derickrethans.nl/feed-phpinternalsnews.xml, you can download this episode's MP3 file, and it's available on Spotify and iTunes. There is a dedicated website: https://phpinternals.news


Transcript

Derick Rethans 0:15

Hi, I'm Derick. Welcome to PHP internals news, a podcast dedicated to explaining the latest developments in the PHP language. This is episode 103. Today I'm talking with George Peter Banyard again, this time about a disjunctive normal form types RFC, or DNF, for short, which he's proposing together with Larry Garfield. George Peter, would you please introduce yourself?


George Peter Banyard 0:39

Hello, my name is George Peter Banyard, I work on PHP paid part time, by the PHP foundation.


Derick Rethans 0:44

Just like last time, we are still got colleagues.


George Peter Banyard 0:46

Yes, we are indeed still call it.


Derick Rethans 0:48

What is this RFC about? What is it trying to solve?


George Peter Banyard 0:52

The problems of this RFC is to be able to mix intersection and union types together. Last year, when intersection types were added to PHP, they were explicitly disallowed to be used with Union types. Because: a) mental framework, b) implementation complexity, because intersection types were already complicated on their own, to try to get them to work with Union types was kind of a big step. So it was done in chunks. And this is the second part of the chunk, being able to use it with Union types in a specific way.


Derick Rethans 1:25

What is the specific way?


George Peter Banyard 1:27

The specific way is where the disjoint normal form thing comes into play. So the joint normal form just means it's a normalized form of the type, where it's unions of intersections. The reason for that it helps the engine be able to like handle all of the various parts it needs to do, because at one point, it would need to normalize the type anyway. And we currently is just forced on to the developer because it makes the implementation easier. And probably also the source code, it's easier to read.


Derick Rethans 1:54

When you say, forcing it up on a developer to check out you basically mean that PHP won't try to normalize any types, but instead throws a compilation error?


George Peter Banyard 2:05

Exactly. It's, it's the job of the developer to do the normalization step. The normalization step is pretty easy, because I don't expect people to do too many stuff as intersection types. But as can always be done as a future scope of like adding a normalization step, then you get into the issues of like, maybe not having deterministic code, because normalization steps can take very, very long, and you can't necessarily prove that it will terminate, which is not a great situation to be in. Imagine just having PHP not running at all, because it's stuck in an infinite loop trying to normalize the format. It's just like, oh, I can't compile


Derick Rethans 2:39

Would a potential type alias kind of syntax help with that?


George Peter Banyard 2:44

Maybe, I'm not really sure.

PHP Internals News: Episode 103: Disjunctive Normal Form (DNF) Types


London, UK

Friday, June 24th 2022, 09:07 BST



In this episode of "PHP Internals News" I talk with George Peter Banyard (Website, Twitter, GitHub, GitLab) about the "Disjunctive Normal Form Types" RFC that he has proposed with Larry Garfield.

The RSS feed for this podcast is https://derickrethans.nl/feed-phpinternalsnews.xml, you can download this episode's MP3 file, and it's available on Spotify and iTunes. There is a dedicated website: https://phpinternals.news


Transcript

Derick Rethans 0:15

Hi, I'm Derick. Welcome to PHP internals news, a podcast dedicated to explaining the latest developments in the PHP language. This is episode 103. Today I'm talking with George Peter Banyard again, this time about a disjunctive normal form types RFC, or DNF, for short, which he's proposing together with Larry Garfield. George Peter, would you please introduce yourself?


George Peter Banyard 0:39

Hello, my name is George Peter Banyard, I work on PHP paid part time, by the PHP foundation.


Derick Rethans 0:44

Just like last time, we are still got colleagues.


George Peter Banyard 0:46

Yes, we are indeed still call it.


Derick Rethans 0:48

What is this RFC about? What is it trying to solve?


George Peter Banyard 0:52

The problems of this RFC is to be able to mix intersection and union types together. Last year, when intersection types were added to PHP, they were explicitly disallowed to be used with Union types. Because: a) mental framework, b) implementation complexity, because intersection types were already complicated on their own, to try to get them to work with Union types was kind of a big step. So it was done in chunks. And this is the second part of the chunk, being able to use it with Union types in a specific way.


Derick Rethans 1:25

What is the specific way?


George Peter Banyard 1:27

The specific way is where the disjoint normal form thing comes into play. So the joint normal form just means it's a normalized form of the type, where it's unions of intersections. The reason for that it helps the engine be able to like handle all of the various parts it needs to do, because at one point, it would need to normalize the type anyway. And we currently is just forced on to the developer because it makes the implementation easier. And probably also the source code, it's easier to read.


Derick Rethans 1:54

When you say, forcing it up on a developer to check out you basically mean that PHP won't try to normalize any types, but instead throws a compilation error?


George Peter Banyard 2:05

Exactly. It's, it's the job of the developer to do the normalization step. The normalization step is pretty easy, because I don't expect people to do too many stuff as intersection types. But as can always be done as a future scope of like adding a normalization step, then you get into the issues of like, maybe not having deterministic code, because normalization steps can take very, very long, and you can't necessarily prove that it will terminate, which is not a great situation to be in. Imagine just having PHP not running at all, because it's stuck in an infinite loop trying to normalize the format. It's just like, oh, I can't compile


Derick Rethans 2:39

Would a potential type alias kind of syntax help with that?


George Peter Banyard 2:44

Maybe, I'm not really sure.

Top podcasts em Tecnologia

Giro do Loop
Loop Infinito
Tecnocast
Tecnoblog
Hipsters Ponto Tech
Alura
MacMagazine no Ar
MacMagazine.com.br
Lex Fridman Podcast
Lex Fridman
Área de Transferência
Gigahertz