Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment One: Implement the Self Object Model Thisour assignment is to implement Self in the language of your choice. No , you don t have

Assignment One: Implement the Self Object Model
Thisour assignment is to implement Self in the language of your choice.
No, you dont have to implement the syntax, just the mechanics of how objects work.
You may use the language of your choice.
An Object
Objects are a collection of slots. A slot is a string name and a reference to another object. Objects can be evaluated, which by default produces a reference to the object itself.
Within an object, some slots are marked as parents.
An object may optionally have a list of messages, separate from the slots. These objects may have a slot called parameter. This is equivalent to a function definition. Evaluating this object copies it, equivalent to creating a function invocation. The messages in the list of messages are then sent to the copy.
An object may instead represent a primitive data value, such as a number. These objects can still have slots that are changeable but have an immutable primitive value instead of a list of messages. Evaluating this object produces a copy with the same primitive data value.
An object may instead represent a primitive function, such as arithmetic. Evaluating this object copies the object as with objects that are lists of messages. But instead of sending messages, the primitive function is called with the copy as a parameter.
Capabilities
Your objects must implement the following capabilities:
evaluate given an object, evaluate it and return the result. If the object has a list of messages, the object copies itself, sends the messages to the copy, and returns the last result.
copy given an object, return a copy of it
sendAMessage - given an object and a string, send the message to the object. The object corresponding to the message (I.e., in the slot with the same name as the message) is evaluated and returned. If the object doesnt directly have a slot with that name, recursively look in the parent slots via a breadth-first search.
sendAMessageWithParameters given an object and a string and a second object (the parameter), send the message to the first object, passing the second object as a parameter to the message by setting the parameter slot on the object. If the object doesnt directly have a slot with that name, recursively look in the parent slots via a breadth-first search.
assignSlot given an object, a string, and an object, set the slot in the first object named by the string to refer to the second object.
makeParent given an object and a string, designate the slot named by the string (if it exists) as a parent slot.
assignParentSlot given an object, a string, and an object, call assignSlot then makeParent.
print given an object, produce a printed representation of the object as a string. Alternatively, you may implement draw, which draws a graphical representation of the object.
Explanation
Your implementation must include sufficient documentation, either as a separate document or as extensive comments, to explain what it is doing and how it works. This should include information on building and running the code. It must explain what language you used and why, and any additional features of your implementation (such as garbage collection, efficiency techniques, or other capabilities not required).
Keep in mind that objects can have multiple parent slots and that the graph of objects may be cyclical.
You also need to explain what parent relationships are between objects with lists of messages (I.e., function bodies) and their copies (I.e., function invocations). Why is this important and what are alternative approaches?
You also need to explain how to implement the equivalent of basic flow of control including the following:
If-then-else statements
Recursion
Loops

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

More Books

Students also viewed these Databases questions

Question

1. Explain the difference between debt finance and equity finance.

Answered: 1 week ago