ID:96044
 
Not Feasible
Applies to:DM Language
Status: Not Feasible

Implementing this feature is not possible now or in the foreseeable future
I would like to have access to a proc, such as "references()" which would accept an object as its only argument, and return an associated list of all places where the object is referenced. Consider the code below:

client
var/reference_holder
verb/test()
var/datum/test_datum = new()
reference_holder = test_datum
var/list/references = references(test_datum)
for(var/object in references)
var/variable_name = references[object]
src << "[object].[variable_name]"


Using that test verb would result in the text "/client.reference_holder" being output to the user. (An open issue here is what to do with temporary variables, such as "test_datum" in the example above.)

Using such a proc we could replace one object with another in a way which effects all places where it is referenced (effectively turning one object into another), or selectively null out references to that object. If this sort of functionality is already present on the back-end as a result of the garbage collector, that would be great. If it's not, then I'll continue to make due without.
While the GC could perhaps do some of this, there are certain internal references I think it would be difficult to impossible to handle here, including local proc vars and arguments. I don't really think this is feasible.
Agreed.