While I am an architect and even after 35 years, I love core coding, a lot of times I go into this “academic” developers mode where I tinker with stuff, get envious of another language and try to replicate it in a different language.
Like the other day someone (Manas Dash) showed me how to create quick enums in Python
RED, GREEN, BLUE = range(3)
All this was just academic interest but then someone said “Hey! You AutoViv doesn’t work in my chart application”. I sat up and said “Hain?”… I didn’t expect anyone to take it seriously. It was just a proof of concept, but then here was someone who was taking it more seriously than I was.
Now someone was using this code and told me that many 3rd party libraries were failing because of these Proxy objects, and also wanted to use Array vivification
Something like this
This made me go back to my tinkering in Non-theoretical Engineer mode (Sorry, Sheldon!)
I had to add 2 things to my original code
- Add support for array vivification
Here is what is looks like now
The guy who is using is seriously said “Cool, it works!” and later said “Oh it works for nested and array too”.
This is still of academic interest to me. I haven’t built this as commercial piece of code or encouraging people to start using Auto-vivification. While it can be convenient, it can introduce more problems in the code with typos
Imagine landing up doing
univ.collage.steam.year = "A+"
and then wonder why it’s not working, because there will be NO errors with auto-vivification. Whatever you do WILL be accepted.
Still, if you want to give this a spin and use it in your side project, let me know how it goes.