Does anyone know when this syntax became disallowed, which now fails the syntax check on compilation? I tried PB 6.20 Windows 64-bit today and found that I needed to assign a dummy value to each new map element, although I only need the key, for this particular app.
This change was made in 6.00, I believe beta 5. I'd have to go dig up the forum thread again, but if you find it, do a search for "passive syntax" I believe and you'll find it. I am not a fan of this change personally as I've stated before, I think that simply attempting to access a key shouldn't create it...talk about typo bugs...
I did once propose having this controlled with EnableExplicit/DisableExplicit, but that went nowhere
Quin wrote: Wed Dec 18, 2024 5:03 pm
This change was made in 6.00, I believe beta 5. I'd have to go dig up the forum thread again, but if you find it, do a search for "passive syntax" I believe and you'll find it. I am not a fan of this change personally as I've stated before, I think that simply attempting to access a key shouldn't create it...talk about typo bugs...
I remember you've mentioned this recently Quin, yes.
It's not this aspect that I'm referring to. I currently run PB 6.00 LTS Windows x64 and my example compiles fine.
PB 6.20 Beta will not compile it. It gives a syntax error. I suppose I hadn't expected that a new version of PB would break my code
Interesting, I figured the change was supposed to solve the complains about keys being created randomly by if statements.
this still works with 6.12LTS x64:
Fred wrote: Wed Dec 18, 2024 6:35 pm
There is always an associated value to a map element, this change was made to avoid error, now it's more explicit that you create an element.
It's a pity that the change prevents existing code from compiling.
Sometimes maps are very useful as a form of key list, but with the benefit of lookup, and hence without need of associated values.
Well it was changed because someone complained he got a bug unnoticed due to a lazy notation. And now you are complaining because you miss the lazy notation (which is not that obvious TBH). So yes we need to make choice and the code change to adapt is very small. As said before, a Map always hold a value, it's not an HashSet, so it's made explicit.
Fred wrote: Thu Dec 19, 2024 6:01 pm
As said before, a Map always hold a value, it's not an HashSet, so it's made explicit.
I understand now — the change was about the notation, rather than avoiding the need for an associated value. The ideal for me, would be to provide the ability to not store an associated value, but that's not possible, I can see that now. No worries.