Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
Com S 342 --- Principles of Programming Languages
HOMEWORK 1: LANGUAGE DESIGN GOALS AND RUNNING SCHEME
Due: problems 1-4 at beginning of class January 27, 2009.
In this homework, learn how to run Scheme, and learn some basic terms
and ideas about programming language design,
For code hand in *both* your printout of the code and a transcript of testing;
handwritten code is *never* acceptable in this class unless the
problem specifically states otherwise.
The section headings below give the readings related to the problems.
STRUCTURE AND INTERPRETATION OF COMPUTER PROGRAMS, Sections 1.1.1-1.1.6
REVISED^5 REPORT ON SCHEME
SCALA RATIONALE
Related to this discussion you should read Sections 1.1.1-1.1.6 of the
recommended textbook Structure and Interpretation of Computer
Programs, by Abelson and Sussman, which is on reserve and also on-line
at http://mitpress.mit.edu/sicp/. For a reference on Scheme,
see the Revised^5 Report on Scheme, which is available in several
formats from the course resources web page.
1. [design goals]
In class, we said that Scheme has three design goals:
simplicity, generality, and the ability to manipulate programs as data.
a. (10 points)
From your experience with C++ (or Java or C#, say which), what do you
think its design goals are?
b. (10 points)
An interesting new programming language is "Scala."
What are its main design goals?
You can find out by reading the "Scala Rationale" on the web at
the URL:
http://scala.epfl.ch/docu/files/ScalaRationale.pdf
Then answer the above and the following questions, writing no more than a half
page for each. Also we'd prefer that you summarize, rather than just quote from
this source, as it shows you're thinking. But be sure to set off in quotation
marks (" and ") anything that you directly quote in your answer.
c. (10 points)
How do the design goals of Scala differ from those of Scheme?
2. (10 points) [means of combination]
What does C++ (or Java or C#, say which) use for its means of combination
that resemble the following in Scheme:
a. (3 points) combinations (i.e., applications of Scheme procedures)
b. (3 points) begin expressions
c. (4 points) if-expressions of the form (if b e1 e2). Be careful...
3. (10 points) [means of abstraction]
Briefly describe two means of abstraction in C++ (or Java, say which).
RUNNING SCHEME WEB PAGE
See the "Running Scheme" web page for details about running Scheme.
4. (10 points) [Setting up DrScheme]
Read the "Running Scheme" web page and follow the instructions to
setup DrScheme environment on your home computer or laptop. Now
do the following to customize your installation slightly.
[I] Find the installation directory for DrScheme. From here on we will
refer to this directory using $DrSchemeHome.
[II] Make a directory $DrSchemeHome/lib/collects/lib342
[III] Create a file in this new directory with the name displayln-mod.scm
Add the following contents to this file.
(module displayln-mod mzscheme
(provide displayln)
(define displayln
(lambda args
(for-each display args)
(newline)))
) ;; end module
Save the file in the directory $DrSchemeHome/lib/collects/lib342
[IV] Change the current directory to $DrSchemeHome/bin
[V] Execute the script "setup-plt" in this directory, which refreshes
your DrScheme installation.
[VI] Now start DrScheme and follow the directions on the "Running Scheme"
web page to set the language in DrScheme to "Essentials of Programming
Languages (3rd ed.)". After pressing the "Run" button at the top of the
DrScheme window, you should see that the "Language" is "Essentials of
Programming Languages (3rd ed.)".
[VII] Now, in the interactions window of DrScheme, evaluate the three forms below,
after changing to your own name:
(require (lib "displayln-mod.scm" "lib342"))
(define my-name "")
(displayln "My name is " my-name)
(Evaluation consists of typing each form into the system, and
pressing the enter key.)
You should see a line of output after the second of these. (If you
get an error, that means you didn't correctly install the displayln-mod.scm
as described in Steps I-VI above.)
Print the interactions window and hand in your printout.