Re: bikeshed: Typed Aliases
| From: | Rowan Tommins [IMSoP] | Date: | Sat, 07 Sep 2024 17:07:59 +0000 |
| Subject: | Re: bikeshed: Typed Aliases | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-125473@lists.php.net to get a copy of this message | ||
On 7 September 2024 17:23:13 BST, Davey Shafik <me@daveyshafik.com> wrote:
>
>My point is that if you talk about type DEFs, you now have this feature where you can input one
>type and get something that encapsulates it, and it seems weird that enums would LOOK similar In
>type hint usage and function differently.
Personally, I would prefer to go the other way: make typedefs, like enums, something you explicitly
construct / cast to, rather than something that implicitly coerces any compatible value.
Like enums, I would want to use typedefs to prevent accidental mixing of values (e.g. a name where a
reference number was expected, or a size in pixels where a size in centimetres was expected). That
use is compromised if every scalar value is silently accepted for any matching typedef.
Regards,
Rowan Tommins
[IMSoP]