Supporting [] for arrays, instead only ()

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
va!n
Addict
Addict
Posts: 1104
Joined: Wed Apr 20, 2005 12:48 pm

Supporting [] for arrays, instead only ()

Post by va!n »

It would be nice to support [] for arrays too, instead only ().
Using () for functions and maybe optional [] for arrays would make the source more readable and make clear if its a function or array.
va!n aka Thorsten

Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
User avatar
Zebuddi123
Enthusiast
Enthusiast
Posts: 796
Joined: Wed Feb 01, 2012 3:30 pm
Location: Nottinghamshire UK
Contact:

Re: Supporting [] for arrays, instead only ()

Post by Zebuddi123 »

+1 But the problem of breaking backward compatibility :cry:

Zebuddi. :)
malleo, caput, bang. Ego, comprehendunt in tempore
User avatar
STARGÅTE
Addict
Addict
Posts: 2226
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Supporting [] for arrays, instead only ()

Post by STARGÅTE »

but then it is not clear, if it is a static array (only []) or a dynamic array (with optional [])?
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
va!n
Addict
Addict
Posts: 1104
Joined: Wed Apr 20, 2005 12:48 pm

Re: Supporting [] for arrays, instead only ()

Post by va!n »

+1 But the problem of breaking backward compatibility :cry:
That's why it could be an optional feature... People can choose to use () or [] for arrays.
Sure, using only [] for arrays would be smarter.
va!n aka Thorsten

Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Supporting [] for arrays, instead only ()

Post by Fred »

Having two ways to write the same code just adds confusion.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Supporting [] for arrays, instead only ()

Post by netmaestro »

I think it would have a place but only if functionality were added, where the new brackets would denote an associative array. Not sure we really need associative arrays in Purebasic as the map object covers most of it. The only gain would be a smaller memory footprint and more efficient code where the number of elements is small, something like less than 50.
BERESHEIT
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: Supporting [] for arrays, instead only ()

Post by davido »

Perhaps the IDE could allow a colour difference to distinguish Arrays from Functions?
DE AA EB
Post Reply