[low priority] CountListItems()

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Michael Vogel
Addict
Addict
Posts: 2798
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

[low priority] CountListItems()

Post by Michael Vogel »

Some PB function names are difficult to remember, many user don't feel happy to write all these hide commands (HideGadget, HideWindows etc.) which look so negative :lol:, for me I have to think twice when searching the right name for the functions to get the number of entries in a gadget or list - what about creating an alias for ListSize() which allows also to use CountListItems() ?
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: [low priority] CountListItems()

Post by Shield »

Why don't you just use a macro?
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
User avatar
Michael Vogel
Addict
Addict
Posts: 2798
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: [low priority] CountListItems()

Post by Michael Vogel »

Shield wrote:Why don't you just use a macro?
At the first moment, I considered to do that (especially if the PB IDE would include something like a "standardinclude.pbi" automatically) -- but it's like these many other procedures and macros (Min, Max, AbsInteger, FindStringRight etc.): sharing code with others will get more complicate, each included function have to be synchronized as well...
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: [low priority] CountListItems()

Post by gnozal »

You may create a custom resident : the macro will be known by the PB compiler without the need of including anything.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: [low priority] CountListItems()

Post by Shield »

Won't solve the problem with sharing code though.
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: [low priority] CountListItems()

Post by Little John »

Officially providing different names for the same built-in function will decrease readability of the code, and will be confusing especially for newbies. I honestly hope that this is not going to happen.
And I can't see any problem with using macros for this purpose, in case soemone individually prefers to use different names.

Regards, Little John
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: [low priority] CountListItems()

Post by skywalk »

Macros are great, except in debug mode. :(
Same is true using With...EndWith.

I do wish earlier on, there was an effort to standardize the core function names.
Take a noun-verb approach instead of verb-noun.
This way the AutoComplete and libraries line up!
And talk about helping out the newbies :wink:

ex.
StringReplace() instead of ReplaceString()
StringRemove() instead of RemoveString()
MemoryAllocate() instead of AllocateMemory()
MemoryCompare() instead of CompareMemory()
~... you get the idea
Then, the functions become intuitive.

StringGadget() wouldn't pop up when I'm typing 'Str', because that would be GadgetString(), along with all the other Gadgetsxxx().

Think how frustrating it would be if the #Constants were verb-noun?
#PB_ActivateWindow_Event instead of #PB_Event_ActivateWindow
#PB_ClientConnected_Event instead of #PB_Event_ClientConnected

Too bad the functions themselves were not similarly named? :(
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: [low priority] CountListItems()

Post by Trond »

I do wish earlier on, there was an effort to standardize the core function names.
The reason we don't have CountList() but do have ListSize() is because it was standardized to match ArraySize() and MapSize().

Edit: It still works, but it's deprecated.

Code: Select all

NewList l()
AddElement(l())
Debug CountList(l())
Post Reply