On Wed, 4 Aug 2021 15:30:35 -0700 Aaron Priven <aaron@priven.com> wrote: > I dont have a problem with the proposal per se, but its hard for me to believe that inferring what type a value should be from its initial assignment is going to be reliable. > > Surely theres a lot of extant code like > > if ($condition) { > $flag = $x eq $y; > } else { > do_something(); > $flag = 1; > } > $count+= $flag; > > Is $flag a boolean or an integer? > > I can appreciate the desire to have serializers work on data without having to pass type information separately, but it seems really unlikely to me that its possible to be consistent without being explicit. if ($condition) { $flag = $x eq $y; # boolean } else { do_something(); $flag = 1; # not a boolean, replace it with !!1 or true } $count+= $flag; # not a boolean Anyway, yes, it won't magically fix all existing code. But it will give the users *a way* to create variables that will reliably serialize as booleans. Of course, often you will have to normalize your values just before passing them to a serializer, but it's still a huge improvement.Thread Previous | Thread Next