Make map key explicit creation be controlled by EnableExplicit

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Quin
Addict
Addict
Posts: 1131
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Make map key explicit creation be controlled by EnableExplicit

Post by Quin »

In PB 6.00, this change was implemented:
PureBasic - History wrote: - Changed : the way the map elements are created when using passive syntax, to be more consistent
I personally don't care too much for this, and would've much preferred if it happened the other way around (i.e. this is always an error). However, there seemingly are users that want this feature, so I propose that we make it controlled with EnableExplicit/DisableExplicit. Existing code can be updated with no issue (extra checks hurt nothing, can easily be removed, but not enough can crash hard). And I assume that if someone's already not using Explicit, they want to suffer... :wink: :mrgreen:
nsstudios
Enthusiast
Enthusiast
Posts: 309
Joined: Wed Aug 28, 2019 1:01 pm
Location: Serbia
Contact:

Re: Make map key explicit creation be controlled by EnableExplicit

Post by nsstudios »

+1
If I'm accessing a non-existing key, I'd want to be warned by debugger, and I suppose when compiled, it could try to access it, and risk crashing like trying to access an out of bounds array element.
Making new keys implicitly just means I can easily run into difficult to find bugs if I misspell the key, and instead of being warned about it, PB pretends as if it were always there.
Post Reply