Page 1 of 1

Make map key explicit creation be controlled by EnableExplicit

Posted: Tue Apr 23, 2024 3:23 am
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:

Re: Make map key explicit creation be controlled by EnableExplicit

Posted: Tue Apr 23, 2024 3:30 am
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.