Re: [RFC] Mixed type

From: Date: Fri, 24 Apr 2020 14:33:24 +0000
Subject: Re: [RFC] Mixed type
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-109828@lists.php.net to get a copy of this message
Actually, I forgot that for proper generics implementations, collections etc. will obviously need to specify "allowing any type". As such the introduction of mixed is pretty much necessary. As in class Foo<A, B> { … } $foo = new Foo<mixed, int>; As such, I'm actually in favor of introducing it. Bob > Am 24.04.2020 um 14:11 schrieb Bob Weinand <bobwei9@hotmail.com>: > > Hey Dan, > > this, I consider one of the few concepts which should never make it into PHP. > > In particular, the main problem with mixed is that it is a very easy "I have no idea how > to type that properly, so just let's use mixed". > > And really, in general, except for some debug functions, mixed is just an excuse to not use > proper generics. I cannot think of non-debug scenarios where we are juggling truly unknown types > where the type is unidirectional. > (Uni-directional means: there is no corresponding getting/forwarding function for an input.) > > Mixed is in almost every case just patching the holes in PHPs type system.. And as such, > I'd rather promote RFCs trying to properly fix the gaps in the type system than supporting > mixed. > > Mixed is a hack, do not use mixed. > > Bob > > P.s.: If you want to migrate your types and have an overview of what's already migrated, > maybe just add a comment // type-migrated before or similar? But that's seriously not the > business of the language. > >> Am 20.04.2020 um 13:17 schrieb Dan Ackroyd <danack@basereality.com>: >> >> Hi Internals, >> >> Here is an RFC for adding a 'mixed' type to the language: >> https://wiki.php.net/rfc/mixed_type_v2 >> The RFC builds on an earlier draft by Michael Moravec. >> >> Part of the motivation for pursuing this RFC was my recent experience >> in upgrading an application to PHP 7.4. >> >> Being able to add types to the application made the code much easier >> to reason about, but there were places where I couldn't add type info >> due to the lack of mixed. That made it hard to see if that piece of >> code had been upgraded (but type info couldn't be added), or if that >> code still needed to be upgraded. >> >> cheers >> Dan >> Ack >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.internals (#109828) next »