ENIGMA Forums

General fluff => Announcements => Topic started by: Josh @ Dreamland on June 19, 2010, 07:12:35 am

Title: Var 4
Post by: Josh @ Dreamland on June 19, 2010, 07:12:35 am
Questions on which to pick and why have boiled down to the need to separate var into individual sources, each implementing a behavior. Var 4 will apparently implement several options.

The first of these is in how arrays are handled:
- GM uses a Map for everything, as some of you know. I guess I could make that an option.
- ENIGMA R3 uses a simple dynamic array. It checks for size, then dereferences O(1).
- Lua uses both. It would implement no additional overhead from R3, but would add some in computing whether it should use the map for large indexes.

The second of these is in how variants store memory.
- GM's method cannot be determined simply through experimentation. Presumably, since it is interpreted, Mark keeps close track of type (an extra check among a map lookup is nothing).
- ENIGMA R3 kept variant next to double for max speed, but high memory usage.
- I am capable of constructing and destroying string on the site, at the cost of an additional check per = operation (and of course, constructor and destructor call). This will reduce memory usage, but slightly(?) lower speed as well.

I will spend today trying to implement them (among other things).
Title: Re: Var 4
Post by: Game_boy on June 19, 2010, 09:26:08 am
This will be the most uninformed comment yet, but it looks to me like most computers have more than enough RAM and are generally CPU-bound out of the two (and GPU-bound if you include graphics due to the widespread use of Intel integrated rubbish). Especially on Dell and HP bought machines which could be considered the 'masses' compared to people who know how a computer works.

So I'd favour speed over memory conservation?
Title: Re: Var 4
Post by: Josh @ Dreamland on June 19, 2010, 02:04:43 pm
That's what I was thinking. In fact, the new instance system also uses quite a bit more memory than the old. We're talking nearly half a megabyte for a game with 1,000 instances at 10 events apiece. But it introduces a beautiful mechanism for the instance functions, and even with() and the like.
Title: Re: Var 4
Post by: Josh @ Dreamland on June 20, 2010, 12:52:48 am
Copy on write will be implemented as well. Basically, scripts can return arrays via this new magic. At no efficiency cost. However, there is a detriment on setting equivalent a var and a large array. Because of that, I believe I will be making as many globals as possible use scalar types. (Or variant if I have to).

Variant will now be a type at the user's disposal. Not boost::variant, just R3's enigma::variant.

Also, string() is handled more beautifully, such that string str; will still get you a string, but string(somevar) will work as well. This is possible via a simple macro, #define string(x) toString(x). (Luckily, string alone will not error nor attempt to unfold the macro function.)
Title: Re: Var 4
Post by: The 11th plague of Egypt on June 21, 2010, 11:57:49 am
I had to read your first post 3 times to understand it. :eng99:

Good to see you are happy to share your thoughts. (Y)
Title: Re: Var 4
Post by: Josh @ Dreamland on June 21, 2010, 12:00:07 pm
Heh.
Also, copy-on-write will introduce a branch of overhead. I'm hoping it's negligible.
Title: Re: Var 4
Post by: The 11th plague of Egypt on June 22, 2010, 06:00:39 am
Seems like we'll have some tests to do :)