Allow pairing keywords "ForEach" and "With"

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

Allow pairing keywords "ForEach" and "With"

Post by Mistrel »

Working with long variable names for collections and ForEach is extremely verbose:

Code: Select all

Structure ListStruct
  fieldA.s
  fieldB.s
EndStructure

Structure SomeStruct
  List someLongListName.ListStruct()
EndStructure

someLongVariableName.SomeStruct

ForEach someLongVariableName\someLongListName()
  Debug someLongVariableName\someLongListName()\fieldA.s+" "+someLongVariableName\someLongListName()\fieldB.s
Next
We can already simplify this with the "With" keyword:

Code: Select all

ForEach someLongVariableName\someLongListName()
  With someLongVariableName\someLongListName()
    Debug \fieldA.s+" "+\fieldB.s
  EndWith
Next
It would be nice if we could combine these together for something even simpler:

Code: Select all

ForEach With someLongVariableName\someLongListName()
  Debug \fieldA.s+" "+\fieldB.s
Next
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Re: Allow pairing keywords "ForEach" and "With"

Post by helpy »

+1

Nice idea!
Windows 10 / Windows 7
PB Last Final / Last Beta Testing
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Allow pairing keywords "ForEach" and "With"

Post by Josh »

If you don't consider the forum 'Feature Requests and Wishlists' as personal property and occasionally use the search function, you will find the following threads in which the same has already been requested:

See here and here

With a simple +1 in one of this two threads we would have been spared another nonsense contribution in the WishLists. If you had also read the posts, you would have encountered the problems it can cause.

BTW, in the six results of my search, I came across a thread of my own that basically concerns the same thing and solves it in the same way as it is used in other programming languages.

See here
sorry for my bad english
Post Reply