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

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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