Is cloning independent of message-passing

I was thinking about constructors in class based languages and how the idea might relate to prototype-based languages, when it occurred to me that if you try to create a prototype-language with message-passing, you'll have to define the basic "clone" operation outside of the message passing framework. Here's a brief description of the thoughts that brought me to this conclusion.

I was considering how I might want to have some code execute whenever a object is cloned -- like a constructor in a class-based language. I could send an "init" message to each object right after it is cloned. But this doesn't describe the process of actually the cloning the object in the first place. So let me define a "clone" method which returns the new object. Let's say the clone method operates by creating a blank object and then adding the parent object's own members to it. But that raises the question: where do we get an empty object? It seems to me that the language runtime has to provide this empty object and that the semantics related to it have to be separate from the semantics for messaging. In other words: you cannot describe object creation purely in terms of sending messages to existing objects.

I wanted to get this idea down in some form while it was still fresh, so it's possible that I'm missing something. I'm not familiar with the formal semantics for non-class-based languages, so if there are papers that contradict (or support) what I just said, please point me towards them.

Thanks.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Reify Runtime or Regions

It seems to me that the language runtime has to provide this empty object and that the semantics related to it have to be separate from the semantics for messaging. In other words: you cannot describe object creation purely in terms of sending messages to existing objects.

Sure you can. You even provided your own answer: reify the runtime object. Or, alternatively, reify regions and the allocation process (which allows developers to subdivide regions and inject control). Object allocation doesn't need to be an ambient authority.

It is quite inconvenient to reify memory management. Dynamic scope - implicit context for messages - can make it slightly less inconvenient, but still leaves a lot to be desired. This inconvenience is only offset if you really need the control (useful for embedded systems and process control).

Objects all the way

So the creation of a new object would involve would involve sending a message to some form of Memory object asking it to allocate space and such?

Quite So

On that subject, you might review Cyclone memory management.

This is the design of the

This is the design of the KeyKOS/EROS/CapROS Space Bank, which allocates Nodes for storing capabilities, and Pages for storing for data. This distinction wouldn't matter in a memory-safe language though.