Page 1 of 1
Enumerate vs. Enumeration
Posted: Wed Aug 31, 2011 8:18 am
by blueznl
This request was triggered by somebody else's post. It's a little expansion on the regular enumeration scheme to make things easier on the eyes...
I would like to have a new keyword ' Enumerate ' which effectively replaces the following macro:
Code: Select all
Macro enumerate(constant)
Enumeration #PB_Compiler_EnumerationValue
constant
EndEnumeration
EndMacro
;
; *** main window
;
Enumerate(#w_main_nr)
Enumerate(#tb_main_nr)
Global w_main_h.i
global tb_main_h.i
;
; *** about window
;
Enumerate(#w_about_nr)
Global w_about_h.i
;
Why not simply use the macro? Because it's easier on the eyes and more consistent with regular PureBasic syntax:
Code: Select all
; using macro
;
Enumerate(#w_about_nr)
Global w_about_h.i
;
; using requested keyword
;
Enumerate #w_about_nr
Global w_about_h.i
The original message that triggered this request is here:
http://www.purebasic.fr/english/viewtop ... 88#p360288
Re: Enumerate vs. Enumeration
Posted: Wed Aug 31, 2011 2:53 pm
by Tenaja
That looks like a great idea!
+1 for me.
Re: Enumerate vs. Enumeration
Posted: Wed Aug 31, 2011 6:07 pm
by Zach
Maybe I don't understand, but that looks like 100% more typing to achieve the same action.
If I want to enumerate a list of constants, all I need to do is provide those constant names. Then reference them in my code.
With your example it looks like, in addition to calling this Enumerate, with the name of what we are enumerating, we must additionally declare it as a global??
That doesn't make sense to me

Re: Enumerate vs. Enumeration
Posted: Wed Aug 31, 2011 7:08 pm
by STARGĂ…TE
@Zach: +1
Constants should not be defined somewhere "on the fly."
This makes the code just confusing!
It is not clearly what value is assigned to the constants, because they are scattered everywhere.
Re: Enumerate vs. Enumeration
Posted: Wed Aug 31, 2011 8:11 pm
by Zach
Well I don't have a problem with defining constants "on the fly", for certain things I guess..
Such as GUI Elements, but still makes them a bit harder to read, personally. But I just don't understand what is easier about defining a constant, then declaring it as a global variable vs ...just defining it as a constant. Or simply doing it on the fly as something=Window/Gadget/whatever(#PB_Any)
I suppose I would need to see comparative real-world examples of both methods used in code, to understand what the benefit might actually be here..
It simply looks like additional typing to me, and another layer of confusion to the person reading it.
Re: Enumerate vs. Enumeration
Posted: Sat Sep 03, 2011 12:07 am
by blueznl
Because, Zach, I am NOT first declaring a constant then turning it into a global. The additional vars were just part of the example (notice the names differ). It's just an attempt to remove 'Enumeration / EndEnumeration' when all you're doing is enumerate one or two constants.
Re: Enumerate vs. Enumeration
Posted: Sat Sep 03, 2011 5:38 pm
by Zach
The names are practically the same, which is causing the confusion, I guess. To me the fact the names are so similar suggests they are connected somehow.
Re: Enumerate vs. Enumeration
Posted: Sat Sep 03, 2011 5:49 pm
by blueznl
Well, Enumerate and Enumeration are similar, which does make sense
I just don't understand how you can be confused by Enumerate vs. for example Global...