Re: [RFC] Mixed type

From: Date: Thu, 30 Apr 2020 23:43:23 +0000
Subject: Re: [RFC] Mixed type
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-109949@lists.php.net to get a copy of this message
Bob Weinand wrote: > Mixed is a hack, do not use mixed. > ... > As such the introduction of mixed is pretty much necessary. > I'm actually in favor of introducing it. Matthew Brown wrote: > I'm opposed to the use mixed in codebases ... > A type system without an explicit mixed type feels incomplete to me. 'I am agree with all'. Mixed is a vital thing....that should be used as little as possible. Marco Pivetta wrote: > I think making mixed very painful to write may be a big > advantage. Everything is a tradeoff, and I think one of the things that PHP does well right is allowing people to choose their own tradeoffs, rather than having a "one true way" of doing things in PHP. Exceptions, eval(), annotations/attributes, and the mixed type are all things that have a vital place, even though they can be used inappropriately. Making something like this painful to use seems a bad choice. It's different from things like json_last_error() or preg_last_error() where doing the easier thing (of not checking those) is always the wrong thing. In particular for people like: Lynn wrote: > I maintain lots of legacy code and I cannot add > return types despite being truly mixed. Mixed is not a > hack, it's a scenario that frequently happens. making things more painful for people maintaining legacy code seems like definitely a bad choice. Gabriel Caruso wrote: > Has the type any been considered? Yes. I think mixed is the better choice for now. There's just so much widespread use of 'mixed' in PHP core, extensions, documentation and userland code that even if 'any' were a slightly better choice long term, taking a choice that would probably be multiple years before it paid off it's cost, seems bad. Ilija Tovilo wrote: > One note: I was wondering if the following > code throws an error (it does): Thanks, updated the RFC. cheers Dan Ack

« previous php.internals (#109949) next »