On Wed, Jan 3, 2018 at 12:21 PM, Andreas Hennings <andr...@dqxtech.net> wrote:
> Another idea I have when reading this proposal is "implicit" typing > based on the initialization. > > E.g. > > $x = 5; > $x = 'hello'; // -> Error: $x was initialized as integer, and cannot > hold a string. > > No, no no. I don't think I'd like that always on approach. However, I just had an idea..... Let's step back. Way back. PHP/FF days back. Back in the day Ramus chose to put variables off on their own symbol table for performance reasons. This isn't as necessary now, but vars in PHP continue to be always $something. Now I don't know the implementation can of worms this would touch but what if this was changed for the locked type variables. That would distinguish them greatly.. int x = 5; Here x is a locked type variable of the integer type. Since it's also on the same symbol tables as the classes, functions, constants et al I presume it is namespace bound as well. var x = 5; If allowed what would this mean? And what to do with class members is an open question. Anyway, I'm looking for an implementation that allows loose and strong typing to coexist even within a given file. I use loosely typed variables most of time myself.