Stack commands

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
MrMat
Enthusiast
Enthusiast
Posts: 762
Joined: Sun Sep 05, 2004 6:27 am
Location: England

Stack commands

Post by MrMat »

Would it be possible for a command to return the free stack space? Also a command to return the current stack space although i'm happy to assume this is 1024k if this isn't possible. Maybe this is technically a difficult thing to do, or perhaps it is just a question of comparing the stack pointer to a base value? I don't know what is required... :?

The reasons for wanting this is when using recursive procedures, eg. sort routines, folder scanning, compression and fractal routines that call themselves - it would be very useful to check the free stack size before the call. At the moment i'm monitoring how much stack space i use myself but this is tedious and makes sharing code difficult, eg. my code has no idea how much stack space is in use when someone else calls it and hence cannot know when the maximum depth is reached.

If this was implemented perhaps the debugger could also check the stack space before doing anything stack related to prevent programs from crashing?

Any comments are appreciated! :-D
Mat