"In Ruby, .dup is just an ordinary method, not a special language construct. I'm pretty sure you could reimplement it in plain Ruby with metaprogramming. You couldn't implement reference creation as a method, as references have to do with how the variable works, not the object itself. It could create a proxy object that references the object, but then the proxy object would have to be special, and it'd be rather clumsy with a proxy object in between all the messages. As for having multiple references to one object, one case would be a "parent" property on a node of some tree structure (e.g. an XML/HTML parser, or the DOM in a browser)."
- NanoTech
"In Ruby, .dup is just an ordinary method, not a special language construct. I'm pretty sure you could reimplement it in plain Ruby with metaprogramming. You couldn't implement reference creation as a method, as references have to do with how the variable works, not the object itself. It could create a proxy object that references the object, but then the proxy object would have to be special, and it'd be rather clumsy with a proxy object in between all the messages. As for having multiple references to one object, one case would be a "parent" property on a node of some tree structure (e.g. an XML/HTML parser, or the DOM in a browser)."
- NanoTech