ID:1918112
 
(See the best response by Pokemonred200.)
What's the equivalent of C, C++ pointers in BYOND? How do I reference data once and point to the address later with other variables. Instead of creating copies?
Best response
Objects, Lists, and Text are stored by reference in BYOND, so technically, you have your pointers with them. However, numbers are stored by value, so to reference a number once you'd need to store it in a list or from an object reference in order to mimic something like C or C++ (Or, if using unsafe code blocks, C#) pointers. However, pointers themselves don't exist. (At the same time, you only copy object references, so it's a shallow copy, instead of copying the object itself (and everything inside of it), which would be a deep copy)
We have enough questions from people who really need help. Quit making our lives more miserable.
You can simulate pointer-like behavior with datums.

pointer
var/data

// 'p' is passed by reference
proc/change_data(pointer/p, d)
p.data = d
Whenever you pass atom or datum objects to a variable, it's converted to a reference to that object. When you pass individual variables, it only passes the value.

This is very powerful functionality and basically the only reason the emitter management code works in my particle engine.

What I would find more useful is a way of copying objects passed to variables without having to copy each individual value it has. I know matrices have this function because New() can take a matrix as an argument and copy everything directly, but it doesn't work with anything else by default.
Thanks Toadfish and Kats.
In response to Kats
Matrices however will only copy the six vars matrices are supposed to have by default. If you add any vars to the datum, a copy won't include them by default.
In response to Lummox JR
I know. The matrix's built-in New() function copies only default variables. How difficult would it be to add a behavior to default atoms to support a clone() function? Something I'm a bit curious about.
I think this would create more trouble than it's worth - you would end up having to guess whether an argument is a reference or a copy in someone's code. Writing your own datum/proc/clone() and then passing clones into a proc as do_something(M.clone()) seems very clear and natural to me.