Re: [POC Patch] Scalar Type Hinting/Casting - Proof Of Concept

From: Date: Mon, 05 Mar 2012 20:21:57 +0000
Subject: Re: [POC Patch] Scalar Type Hinting/Casting - Proof Of Concept
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-58621@lists.php.net to get a copy of this message
Hi Daniel, No, it is not inspired from the short ternary operator. It's a rather common conversion. C# has a similar notion of nullable types (with totally different mechanics however). By the way, in this particular area PHP's type system is more sound than that of C#, because null is not just a special value of any type but it is a value of a separate null type. Kudos to the original designers for this choice. Your proposal for (int unset) is not very far away from what I propose. In PHPDoc, and in many IDEs, there are often mixed types like these: int|string int|null string|bool|null bool|null DateTime|null ... Of all different combinations, the ones between a type and null are very usual. So, I propose "int?" as a shortcut for "int|null". In that sense, it is totally equivalent to "int unset" that you say. Personally, I find "unset" not proper for this case, because it is not going to unset anything that is not already null. > BTW: Order would equal what is type casted OR simply accepted! Do you have any examples where this could be useful? Lazare INEPOLOGLOU Ingénieur Logiciel 2012/3/5 Daniel Macedo <admacedo@gmail.com> > > This could be usefull for other instances as (string null) or (bool > > null) as well... Your thoughts? > > Typo! The examples should read (string unset) and (bool unset) > > BTW: Order would equal what is type casted OR simply accepted! > > ~ Daniel Macedo >

« previous php.internals (#58621) next »