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

Implementing this feature is not possible now or in the foreseeable future
This suggestion is related to the "references()" feature suggestion, ID:1465. I would like to have a proc, such as "replace(var/datum/object1, var/datum/object2)", which would replace all references to object1 with references to object2. In this way one object could be made to "transform" into another, or all references could be nulled out by passing null as the second argument.

This leaves the problem of accessing the original object, as any reference to it is now lost. To remedy this, I suggest having the function return a reference to the original object, so that the developer can continue to work with it if need-be.
While this is an interesting notion and possibly doable (more so than the references() suggestion), I think the fact that the question comes up is a red flag on the design behind it.

What you should probably consider is having a more mutable parent type that can change just by changing a few simple vars (a proc could take care of that), and if you need for some reason to look up all objects of a given type then you could always register the objects with this "virtual type" in a list for easy access.

var/list/virtual_types = new

proc/VirtualTypes(t,s)
var/list/typelist = virtual_types[t]
if(!typelist)
typelist = list()
virtual_types[t] = typelist
. = typelist[s]
if(!.)
. = list()
typelist[s] = .

datum
var/subtype

proc/SetSubtypeVars(new_subtype)
subtype = new_subtype || subtype
switch(subtype)
// change the vars for this object type
...

proc/ChangeSubtype(new_subtype)
var/list/oldlist = subtype && VirtualTypes(type,subtype)
SetSubtypeVars(new_subtype)
var/list/newlist = subtype && VirtualTypes(type,subtype)
if(oldlist != newlist)
if(oldlist) oldlist -= src
if(newlist) newlist += src
Lummox JR wrote:
While this is an interesting notion and possibly doable (more so than the references() suggestion), I think the fact that the question comes up is a red flag on the design behind it.

I would have to agree with you. Right now, the only reason I'd want to use a replace() proc would be to null out all references to an object without deleting it, which could be done with a call like "replace(object, null)".

In the past there have been one or two times where I wished for such a proc, but in those cases it was only because DM doesn't have multiple inheritance. I think that's when I wrote this article of dubious quality.
Ter13 resolved issue (Not Feasible)