DeleteElement() return value as official feature

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Regenduft
Enthusiast
Enthusiast
Posts: 121
Joined: Mon Mar 02, 2009 9:20 pm
Location: Germany

DeleteElement() return value as official feature

Post by Regenduft »

At the moment DeleteElement() is returning non-zero if there is a current element after deleting and it is returning zero if there is no current element after deleting.

PureBasics help file says, that DeleteElement() has no return value. Since the (de facto) return value is very useful, it would be nice to make it an official feature, so you can rely on it.

Code: Select all

NewList a()
Debug AddElement(a())    ; = 31202064
Debug AddElement(a())    ; = 31202096
Debug AddElement(a())    ; = 31202128
Debug ""
Debug DeleteElement(a()) ; = 31202112
Debug DeleteElement(a()) ; = 31202080
Debug DeleteElement(a()) ; = 0
Debug ""
Debug DeleteElement(a()) ; = 0

Code: Select all

NewList a()
Debug AddElement(a())    ; = 29891344
Debug AddElement(a())    ; = 29891376
Debug AddElement(a())    ; = 29891408
Debug ""
FirstElement(a())
Debug DeleteElement(a()) ; = 0
Debug DeleteElement(a()) ; = 0
;...
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: DeleteElement() return value as official feature

Post by freak »

At the moment you cannot rely on it. The C function is defined as "void", so the return value is whatever was left in the 'eax' (or rax) register when the function exited. This is not reliable.
quidquid Latine dictum sit altum videtur
Post Reply