ID:132927
 
When a list is passed to a variable and you make changes to the variable, the changes are reflected in the list.

When a variable is passed to another variable and you make changes to the second variable, the changes are NOT reflected in the original variable.

How difficult would it be to allow BYOND to force variables to act in the first manner?

Example:
mob/var/MyVariable=1


var/MyVar==mob/var/MyVariable //Probably would want a different syntax to avoid confusion with equality checks, but this is just an example
MyVar++
world<<"[MyVar], [MyVariable]" //Outputs 2, 2
AJX wrote:
When a list is passed to a variable and you make changes to the variable, the changes are reflected in the list.

When a variable is passed to another variable and you make changes to the second variable, the changes are NOT reflected in the original variable.

How difficult would it be to allow BYOND to force variables to act in the first manner?

Probably considerably difficult. What you're referring to is a reference variable, a concept that BYOND doesn't really support as such. I don't think it's impossible, but it would involve a level of compiler mastery I have not yet achieved.

If you want references though, a simple way to do that is to stick your vars into a datum and then just pass the datum.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
If you want references though, a simple way to do that is to stick your vars into a datum and then just pass the datum.

Yea, that was a concept I thought of (and was suggested by IanPeregrine in my other thread) but I don't want to have a datum for every player...

Well actually, question:

What would the performance difference between having a buncha lists on mob and having a buncha lists on a datum attached to a mob?

I.E: Any speed difference in changing
mob/var/list/ListyList
//---------

var/list/X=ListyList

to
mob/var/VarDatum/D
VarDatum/var/list/ListyList
//---------

var/list/X=D.ListyList


I'm not sure if it would take longer or not... Don't really have any concept of the efficiency in this situation. If there really isn't difference then this would be a much easier solution.