Retire the keywords Array, List, and Map

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Retire the keywords Array, List, and Map

Post by Mistrel »

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.
Last edited by Mistrel on Thu Jul 19, 2018 5:21 pm, edited 1 time in total.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Retire the keywords Array, List, and Map

Post by wilbert »

I really don't see the problem.

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
but to me _list looks better in this case :)
Windows (x64)
Raspberry Pi OS (Arm64)
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: Retire the keywords Array, List, and Map

Post by Mistrel »

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.
Post Reply