Creating a function invocation

Assignment Help Basic Computer Science
Reference no: EM133657253

Assignment One: Implement the Self-Object Model

Your assignment is to implement Self in the language of your choice.

No, you don't 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 doesn't 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 doesn't 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

Provide source code, and your explanation

Reference no: EM133657253

Questions Cloud

Identify possible social media smart objectives for client : Identify four possible social media SMART objectives for your client. Identify metric that can be used to assess the success of a social media campaign design.
Change annotated bibliography to synthesis : Change this annotated bibliography to a synthesis of the findings in the literature that led to the development
What unix command should i use : I just logged back into a remote server and I want to see if the program I started running yesterday is still running. What Unix command should I use?
Is marvel or dc the best franchise : Is Marvel or DC the best franchise? Is it better to work to live or live to work? Is American football or soccer better? Are movies or books better?
Creating a function invocation : Evaluating this object copies it, equivalent to creating a function invocation. The messages in the list of messages are then sent to the copy.
Tested against placebo in clinical trials : The myth I decided to choose was COVID-19 vaccines are not being tested against a placebo in clinical trials.
Create an extensive presentation of events : Create an extensive presentation of events that occur in Steinbeck's novel, including when events happened and how the events show that the novel is a parable,
Health care managers ensure that technology implementation : How can health care managers ensure that new technology implementation and use is appropriately communicated to staff and patients?
Describe in detail the experience and tell why : The worst feeling. Describe in detail the experience and tell why. The worst taste. Describe in detail the experience and tell why.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Organization information systems

Even with the best security system, an organization's information systems are never fully safe from outside attacks or malicious activities from insiders. As a result, an organization must be prepared to take curative measures when an incident occ..

  Interior gateway protocol

Prove this statement wrong: When making a decision about which Interior Gateway Protocol (IGP) to use in an enterprise network environment

  Give a counterexample to illustrate this point

Give a counterexample to illustrate this point.

  Essay on theory with a discussion of childhood

Why does bell hooks begin her essay on theory with a discussion of her childhood? What is the relationship between childhood and theory, in her view?

  Cognitive principles of interface and its application

Write a 2 to 3 pages on Relationship and Connection Between Cognitive Principles of Interface and Its Application to Human Computer Interaction

  User interface designs

User Interface Designs. discuss what makes each of your selected sites quality user interface design or inferior user interface design for its intended purpose

  What was the growth rate from 2014-2015

In 2015 per capita Real GDP was $22,030 in Sweet Potato Hollow. What was the growth rate from 2014-2015.

  The smart phone as dangerous technology

What methodology are you planning to use? Theoretical Framework/Background. Describe the connection of the topic to the program goals and courses

  How would you go about determining accuracy

How would you ensure the highest level of accuracy with your simulation, and how would you go about determining accuracy?

  Page for the time of development

View this video about setting SMART goals:Decide on one goal you have that led you to pursue continued education.Complete the SMART Goals Worksheet on the following page for the time of development:

  What are the additional requirements of a class

When an ADT deals with dynamic memory management, what are the additional requirements of such a class in c++?

  Draw the circuit for a 2-input xnor gate

Draw the circuit for a 2-input XNOR gate using at most two tri-state elements (tri-state buffer or tri-state inverter) and one inverter.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd