SA-MP Forums Archive
Question about enums - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Question about enums (/showthread.php?tid=622231)



Question about enums - NeXoR - 20.11.2016

Hey there, does an enumerator use memory ?
Or is it really just similar to a define


Re: Question about enums - AndySedeyn - 20.11.2016

-Wrong-


Re: Question about enums - Nero_3D - 20.11.2016

No they aren't stored in memory

An enum is just an easy way to create a list of tagged / untagged constants


Re: Question about enums - BiosMarcel - 20.11.2016

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
No they aren't stored in memory

An enum is just an easy way to create a list of tagged / untagged constants
Actually that's wrong, all variables are stored in ram(Or in some cases in the CPU cache? dunno) , even the code is, how else would you have the speed that you need, obviously not by storing variables on hard drive.


Re: Question about enums - SickAttack - 20.11.2016

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
Actually that's wrong, all variables are stored in ram(Or in some cases in the CPU cache? dunno) , even the code is, how else would you have the speed that you need, obviously not by storing variables on hard drive.
They aren't variables. Enumerator = iterator/list of consecutive constants. Enumerators don't store values. You can do pInfo:6, just like 6. But you can't give a tag to that specific index without an enumerator.

So you're the one that's wrong.


- BiosMarcel - 20.11.2016

but where is it stored if not in the memory? All information has to be stored somewhere not just variables, so explain pls

Or do u mean that they are replaced on compiletime?


Re: Question about enums - SickAttack - 20.11.2016

Enumerators are the same as macros. Variables with assigned enumerators are the ones storing things.

P.S. Double posting isn't allowed. Use the edit button.


Re: Question about enums - BiosMarcel - 20.11.2016

u didn't get my point i think ^^ what i meant was, that not only values are be stored (depending on how u define stored).


Re: Question about enums - SyS - 20.11.2016

no they are just constant values and not variables .They are not saved in the memory


Re: Question about enums - Kaliber - 20.11.2016

There get replaced from the pre-compiler to constants..for example:

PHP код:
//Before pre-compiler
enum x
{
    
a,
    
b
};
new 
test[x];
test[a] = 5;
test[b] = 6;
//After pre-compiler
new test[2];
test[0] = 5;
test[1] = 6