Cloning only when necessary

Hi,

if you want to make sure you get a copy of an instance that nobody
else has access to you can #clone it. That’s not necessary if the
instance is immutable or frozen (or both). Does anybody think it is a
good idea to implement this? E.g.

class Object
def frown
frozen? ? self : clone
end
end

class Numeric
def frown
self
end
end

The you can do in constructor code for example

def initialize(something)
@x = something.frown
end

and be sure that you do not face aliasing issues with @x. Does
anybody think we should have this in the language?

Note: The name is remotely inspired by “FReeze” and “OWN”. I’m not
religious about it, not at all. It’s just that I could not make up a
better one. Suggestions welcome.

Kind regards

robert