I've never commented on this but it's always bothered me. Basically, these three keywords are equivalent to some of the most common data structures used in programming and, because PureBasic is not case-sensitive, we can't use any form of them as variable names without them being colorized and case-corrected.
For temporary variables that I want to clearly define as one of these collections I have to use weird names like "_list" or something.
The reason for these keywords is to provide a hint for the compiler when using these collections within structures and as procedure parameters. I would much rather see the "Dim", "NewList" and "NewMap" re-used for this purpose to return these keywords to us.
To clarify for others why this isn't an issue in other languages, PureBasic is unique in that these are reserved keywords which means that they can NEVER be used for anything else. In most other languages the words "list/List", etc. are both case-sensitive, scoped, and usually require the explicit inclusion of a standard library before they exist.
I'm sure that this will never be accepted but it's always been something that annoyed me. PureBasic collections have always been this weird facet that does serve a useful purpose but has never really meshed well with the rest of the language.
Retire the keywords Array, List, and Map
Retire the keywords Array, List, and Map
Last edited by Mistrel on Thu Jul 19, 2018 5:21 pm, edited 1 time in total.
Re: Retire the keywords Array, List, and Map
I really don't see the problem.
This seems to work finebut to me _list looks better in this case
This seems to work fine
Code: Select all
NewList List.l()
AddElement(List())
List() = 1
AddElement(List())
List() = 2
AddElement(List())
List() = 3
ForEach List()
Debug List()
Next
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
Re: Retire the keywords Array, List, and Map
It works but it gets colorized and case corrected. Trying to read any code that does this would be a real wtf moment.
Maybe it would be possible to let us disable these keywords from the IDE? Again, I highly doubt we'd get this but I fooled around a bit and couldn't make anything that break using "List" as a variable or structure name anywhere. So it seems like it might work without retiring the keywords.
Maybe it would be possible to let us disable these keywords from the IDE? Again, I highly doubt we'd get this but I fooled around a bit and couldn't make anything that break using "List" as a variable or structure name anywhere. So it seems like it might work without retiring the keywords.