Allow use of [] for lists and arrays
Allow use of [] for lists and arrays
Allow use of [] for lists and arrays as an alias for (),
improves code readability as procedures and functions and macros can easily be distinguished from arrays and lists.
Example:
Dim MyArray.l[41]
MyArray[0] = 1
MyArray[1] = 2
Example: Multidimensional array
Dim MultiArray.b[NbColumns, NbLines]
MultiArray[10, 20] = 10
MultiArray[20, 30] = 20
Example:
NewList MyList.l[]
AddElement(MyList[])
MyList[] = 10
AddElement(MyList[])
MyList[] = 20
AddElement(MyList[])
MyList[] = 30
ForEach MyList[]
Debug MyList[]
Next
improves code readability as procedures and functions and macros can easily be distinguished from arrays and lists.
Example:
Dim MyArray.l[41]
MyArray[0] = 1
MyArray[1] = 2
Example: Multidimensional array
Dim MultiArray.b[NbColumns, NbLines]
MultiArray[10, 20] = 10
MultiArray[20, 30] = 20
Example:
NewList MyList.l[]
AddElement(MyList[])
MyList[] = 10
AddElement(MyList[])
MyList[] = 20
AddElement(MyList[])
MyList[] = 30
ForEach MyList[]
Debug MyList[]
Next
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
Unless Fred & Freak have something else planned for [], then it also gets my vote - but over time get rid of the old syntax?
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
Couldn't this be accomplished easily with 2 macros just as easily?Rescator wrote:Allow use of [] for lists and arrays as an alias for (),
improves code readability as procedures and functions and macros can easily be distinguished from arrays and lists.
Code: Select all
Macro [
(
EndMacro
Macro ]
)
EndMacro
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
What makes you think that? As it works now macros, procedures and native functions/commands all use () and the compiler can distinguish them internally.#NULL wrote:but then the static arrays in structures are messed.
Good point on static arrays in structures but. When would you ever do a
;Not allowed, dynamic array
Structure blah
array.b(4)
EndStructure
Structure blah
array.b()
EndStructure
Structure blah
array()
EndStructure
;Allowed, static array
Structure blah
array.b[4]
EndStructure
? am I missing something or?
I always assumed that the only arrays allowed in structures this way was static ones so I do not see any conflict issues if [] is allowed as an alias for list and dynamic arrays.
As dynamic arrays or lists would never be used/allowed like that anyway right? So the compiler would still be able to distinguish static vs dynamic arrays and lists.
It also kind of makes sense as [] would then be used for lists, dynamic arrays, and obviously static arrays as currently.
And () would be used for procedures, functions, and macros where applicable.
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Re: Allow use of [] for lists and arrays
Maybe syntax coloring could help.Rescator wrote:... improves code readability as procedures and functions and macros can easily be distinguished from arrays and lists.

For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Re: Allow use of [] for lists and arrays
Indeed it would increase the readability of a code, but personally, I got used to ( and ).
I don't like [ and ], because the german keyboard layout is very inconvenient:I don't like to use AltGr everytime I want to type the name of an array or list, Shift is better.
I don't like [ and ], because the german keyboard layout is very inconvenient:
Code: Select all
Shift + 8 (
Shift + 9 )
AltGr + 8 [
AltGr + 9 ]
PB 4.30
Code: Select all
onErrorGoto(?Fred)
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
Re: Allow use of [] for lists and arrays
so, alternatively as Rescator suggested, it would be ok, tho I don't see much advantage, but it's just a matter of taste.Rescator wrote:Allow use of [] for lists and arrays as an alias for ()
as long I can stick to %28 and %29, I don't mind any aliases...
Anyways, some more dynamic syntax coloring as gnozal suggested maybe the better idea,
but that is an IDE change no Compiler change...
oh... and have a nice day.
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Re: Allow use of [] for lists and arrays
+1AND51 wrote:I don't like to use AltGr everytime I want to type the name of an array or list, Shift is better.
Same on french keyboards, probably on most non english keyboards ?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Re: Allow use of [] for lists and arrays
That's why I bought a US layout keyboard, it's less hassle to entergnozal wrote:+1AND51 wrote:I don't like to use AltGr everytime I want to type the name of an array or list, Shift is better.
Same on french keyboards, probably on most non english keyboards ?
the German Umlauts by typing in a combination of keys once
in a while than to ruin your wrist over the time with AltGr + ...

+1 to the request btw...
Windows 7 & PureBasic 4.4