Enumerate vs. Enumeration

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Enumerate vs. Enumeration

Post 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
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: Enumerate vs. Enumeration

Post by Tenaja »

That looks like a great idea!

+1 for me.
Zach
Addict
Addict
Posts: 1675
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: Enumerate vs. Enumeration

Post 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 :oops:
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Enumerate vs. Enumeration

Post 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.
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
Zach
Addict
Addict
Posts: 1675
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: Enumerate vs. Enumeration

Post 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.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: Enumerate vs. Enumeration

Post 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.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Zach
Addict
Addict
Posts: 1675
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: Enumerate vs. Enumeration

Post 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.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: Enumerate vs. Enumeration

Post 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...
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Post Reply