Plus and minus for Enumeration

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Seymour Clufley
Addict
Addict
Posts: 1264
Joined: Wed Feb 28, 2007 9:13 am
Location: London

Plus and minus for Enumeration

Post by Seymour Clufley »

I've been thinking about this for a while:

Code: Select all

Enumeration 5
  #brekn
  #eicnx
  #rerom
  #lvowh +1
  #wtbcu
  #gbsot
  #stbci -2
  #dtisx
EndEnumeration
Any takers?!
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Re: Plus and minus for Enumeration

Post by Kaeru Gaman »

ö.Ö

... in your example #dtisx would be the same as #wtbcu ... ?

in my eyes, Enumeration is made to get a row of values without gaps and without doubles...

but ok, since we can have = in enums, why not + and - ? *shrug*
oh... and have a nice day.
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Plus and minus for Enumeration

Post by Demivec »

I don't think it's readable. It took me a few guesses to figure it out and I'm still not sure if I'm right about what you intended to have happen with that sample code.

Based on my guess I would discourage this feature request.

It can already be done this way:

Code: Select all

Enumeration 5
  #brekn
  #eicnx
  #rerom
  #lvowh = #PB_Compiler_EnumerationValue + 1
  #wtbcu
  #gbsot
  #stbci = #PB_Compiler_EnumerationValue - 2
  #dtisx
EndEnumeration
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: Plus and minus for Enumeration

Post by DoubleDutch »

+1 (lol!)

I think it should be added, the + would be really useful (possibly the - too, but not as much as the +).
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Perkin
Enthusiast
Enthusiast
Posts: 504
Joined: Thu Jul 03, 2008 10:13 pm
Location: Kent, UK

Re: Plus and minus for Enumeration

Post by Perkin »

I thought the whole point of Enumeration is to give a set of #Constants a value which are unique in the set.
If you start mucking about adding and subtracting, why bother with the Enumeration at all, why not just define them all yourself.
I can't see any point for this addition (pun not intended).
%101010 = $2A = 42
Franky
Enthusiast
Enthusiast
Posts: 213
Joined: Sat Apr 26, 2003 2:58 pm

Re: Plus and minus for Enumeration

Post by Franky »

Should the + just work for that single constant in the line with "+" or should it Step above some numbers for every constant?

Code: Select all

Enumeration 5
#Erste ;=5
#Zweite+5 ;=11 or 10?
#Dritte ;=6 or 11 or 12?
IMHO, an exponential Enumeration could be usefull to create Tags for Procedure Parameters.
You know, like #PB_Window_Invisible=2^28

Code: Select all

Enumeration 2 Exponential
#Tag_Do ;=2
#Tag_Save ;=4
#Tag_Debug ;=8
EndEnumeration
This would be nice :)
Give Up everything but trying!
User avatar
Blue Steel
Enthusiast
Enthusiast
Posts: 132
Joined: Wed Aug 31, 2005 4:49 pm
Contact:

Re: Plus and minus for Enumeration

Post by Blue Steel »

why would you want to do anything like that...
to me you may as well simply be setting that value manually if thats the case

to me enumeration is just that like a for x=1 to 10 and setting each variable in that loop to the new value.. staps in enumeration i can inderstand ie: step 5 .. so it goes up in 5's but to me doing any math or subtraction is not what enumeration is for. but then i guess thats just me
Currently using PureBasic 4.51(x86)

Image http://www.codingmonkeys.com
Covers many languages including PureBasic
Post Reply