More Datasection/Const Flexibility

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
GenRabbit
Enthusiast
Enthusiast
Posts: 151
Joined: Wed Dec 31, 2014 5:41 pm

More Datasection/Const Flexibility

Post by GenRabbit »

I'd like to have these posibilities; It would be nice to let the compiler calculate it so You don't have to do it at runtime. (less Variables to keep track of)

Code: Select all

#LENGTH_WORD = 2

DataSection
    BeginMaxActorsInGroup:
    Data.w 5,10,15,20,25,50,100,250,500,1000
    EndMaxActorsInGroup:
    Data.l (?EndMaxActorsInGroup - ?BeginMaxActorsInGroup) /#LENGTH_WORD                 ; This one
EndDataSection

#DataLength = (?EndMaxActorsInGroup - ?BeginMaxActorsInGroup) /#LENGTH_WORD        ; This one
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Re: More Datasection/Const Flexibility

Post by GPI »

I think, the problem is, that address are calculated during realtime. For a human it is easy to see, that the length is a fixed value, but the compiler has problems here.
maybe it is possible to extend the SizeOf()?

SizeOf(BeginMaxActorsInGroup,EndMaxActorsInGroup)
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Re: More Datasection/Const Flexibility

Post by nco2k »

personally i would be happy if we could assign labels to constants in general:

Code: Select all

#Test = ?blahblahblah
DataSection
  blahblahblah:
    Data.b $74, $65, $73, $74, $00
EndDataSection
dont other languages support something like this? it should be doable.

c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
GenRabbit
Enthusiast
Enthusiast
Posts: 151
Joined: Wed Dec 31, 2014 5:41 pm

Re: More Datasection/Const Flexibility

Post by GenRabbit »

I suppose the compiler could flag the variables as it registers them if they are static or dynamic. NCO2K example could be added simultanously
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: More Datasection/Const Flexibility

Post by Tenaja »

nco2k wrote:personally i would be happy if we could assign labels to constants in general:

Code: Select all

#Test = ?blahblahblah
DataSection
  blahblahblah:
    Data.b $74, $65, $73, $74, $00
EndDataSection
dont other languages support something like this? it should be doable.

c ya,
nco2k
Yes, we have that already.
Post Reply