Index: Lab basics, Register, DrScheme, Netscape, News, Logging out
The main goals of this lab are to ensure that you can
All labs are held in Ryon 102 (the southwest corner); all will be held in the back section.
Sections:
The labs for Comp210 complement the lecture. The labs focus on providing additional examples and hands-on work to reinforce the lecture. Note that the Tuesday labs will sometimes cover material from the next day's lecture.
Also, the labs cover utilitarian details not covered in lecture, such as how to use different software packages and (later in the semester) aspects of C syntax. These topics are important for doing the homework, but would be distracting from the overall flow of the lectures.
There will be weekly lab web pages, but no graded assignments beyond the homeworks distributed in lecture.
After each weekly lab session, be sure to look over that lab's web page: most of the material will be familiar from lab, but sometimes there isn't enough time in lab to cover every topic. You may be held responsible for knowing any information on the lab web pages which isn't marked as supplemental.
You should have an Owlnet account already. Freshmen usually receive accounts during O-week. If you do not already have an account, go to the information desk in Mudd.
First, we need to "register" for this course. This will tweak your computing environment to simplify access to the course tools. In one of the xterm windows, type register comp210 (followed by the Return key). Answer y (yes) to any questions it asks.
For most of these changes to have effect, log out and then log in again. The most visible change is that there is now a small menu for Comp 210 on your screen.
registering is not necessary, but should be done unless you
are very familiar with UNIX. This command alters several files,
including your .cshrc and .twmrc, adding
things to your
If you have a problem registering, you probably have changed your windowing environment substantially from the Owlnet default. Talk to a labby or Mudd consultant after lab.
Start DrScheme by either
First, from the Language menu, select Configure Language. From the
menu that gives you, select Beginner. DrScheme then says to restart
the program, i.e., exit DrScheme and then start it again.
When set at Beginner, DrScheme can catch more errors for you:
namely, errors which are technically legal scheme, but are
in all probability not what you really want
(e.g. passing if
two arguments, instead of three).
The DrScheme window is divided into two halves. The lower half, or interaction window, is the real Scheme calculator. The top half, or definition window is merely a text editor (which is smart about indenting Scheme, and such).
Try entering some small Scheme expressions in the interaction window (bottom). DrScheme will respond with each expression's value:
This is also an example that you can simply type in an identifier to see if it's used. E.g., what's the name of a function for negating a boolean? You haven't seen it yet, so try entering negate as your guess. Well, that gives an error, so try entering not. Well, that is defined, so let's see if it's the right thing: try entering (not #t). Yep, it responded #f. It looks like it's probably the right thing.
To evaluate expressions like (* 3 x), we need to make definitions in the definition window. But when we do, we need to load those definitions into the interaction window.
Note again that DrScheme visually matches parentheses to help you make sure that you typed everything correctly. As an additional check, select the Check Syntax button. This checks the entire definition window for syntax errors, and annotates your code, e.g., highlighting identifiers with color.
To use your definition, select the Execute button. This essentially starts DrScheme afresh in the bottom window, and then sends all the text from the definition window (top) down to the interaction window (bottom), as if you had typed it very very quickly. Now enter (* 3 x) in the interaction window -- it responds with 15.
Let's try some additional definitions.
Note again the parenthesis matching. Also, move the cursor onto each of the opening and closing parentheses and note how DrScheme highlights the appropriate section of code.
Load the definition by selecting the Execute button. Enter (square 5) (in the interaction window) -- it responds with 25, of course.
In order to read your definitions more easily, it's generally helpful to put some English comments before each definition. In Scheme, a comment begins with a semicolon and ends with the end of that line, e.g.,
; returns the square of a number (define square (lambda (n) (* n n)))Comments are ignored by the computer -- they are only to help the human reader of the program (which could be you, the programmer, as it can be easy to forget what a program is supposed to do). Even better for this example, because it's more precise is
; square: number -> number ; returns the square of a number (define square (lambda (n) (* n n)))Where the first comment line in notation meaning that the function square takes a number as input and returns a number as output.
It is also important to test your code. Let's test our simple definition of square. In the interaction window, we can try
(square 5)and it responds with the answer 25. This is a really simple program, but we could still try a couple more examples. With more complicated programs, testing becomes very important.
On most assignments, you will need to turn in your tests, as well as your code. For convenience, we will put these tests together with the code, but in comments. For example, cut (this command is in DrScheme's Edit menu) from the interaction window our test of
> (square 5) 25and paste (again in the Edit menu) this below the definition of square, and comment out the test:
; square: number -> number ; returns the square of its argument (define square (lambda (n) (* n n))) ;> (square 5) ;25Keeping the > prompt in there helps distinguish what was the test expression, and what was its result.
(If you are already familiar with Netscape, play around with DrScheme some more, or browse the Comp 210 pages.)
Netscape is a window-based program that displays hypertext documents from the World-Wide Web (or Web, for short). Hypertext documents can contain text, pictures, sound, movies, and (perhaps most importantly) links to other documents. The World-Wide Web (WWW) is an interconnected collection of these hypertext documents. The act of browsing the Web for documents is often called "Web surfing", "net surfing".
To run Netscape, either
The first time that you use Netscape, it will display a license agreement. Read it and click on the Accept button. Netscape will then display a window stating your account has not yet been initialized for Netscape. Click on the OK button to initialize your account; Netscape will respond by creating some special files in your account and displaying the Owlnet "home page".
In a hypertext document, phrases highlighted by color and underlining are linked to other pages; click on them to see that reference (no matter where it is in the world). Try it! To return to the previous page, simply click on Netscape's most useful button: the Back arrow near the top left of the window.
The Netscape window has a scrollbar (when necessary) on the right side. It behaves differently that the xterm's scrollbar: click with the left button above or below the highlighted part to scroll up or down, respectively.
You can directly access an arbitrary Web document by typing into the "Location" edit box near the top of the Netscape window. Fortunately, you rarely have to specify a URL ("Universal Resource Locator"), i.e., an explicit location name, while net surfing. Access the Comp 210 home page at www.owlnet.rice.edu/~comp210.
Selecting the link labeled "Labs", followed by the link "Lab 1" will give you this handout. Surf some of the other links. After lab, you should look through the Comp 210 home pages, which contain office hours, homework, a link to the course newsgroup, previous years' notes, and more.
If you find a document of particular interest, you can remember it by creating a "bookmark" for it: pull down your Bookmarks menu, and select Add Bookmark. Any time you want to revisit that page in the future, you can just select it from the Bookmark menu (where it is now listed).
To see what else the web is good for, here are a few samples:
(Once you are familiar with a Unix editor, you may want to create your own home page. To see what a web page really looks like, select Document Source under the View menu of Netscape.)
To exit Netscape, select Exit from the File menu.
Newsgroups are electronic bulletin boards where everybody can post and read articles on certain topics. There is a newsgroup specifically for this course, rice.owlnews.comp210. You should read the newsgroup every day or two, as helpful hints and clarifications are posted there regularly. Also, if you have a question relating to the course, post it to the newsgroup. Similarly if you have an answer for somebody else's question!
In newsgroups, the idea is that once you've read a message, you probably don't ever want to see it again. So your newsreader "marks" an article as read, and next time you read news it only presents you with unmarked articles. (You have the option of unmarking read articles.)
There are many different news-reading programs you can choose from. Two leading contenders are Netscape and Pine, each of which makes reading news analagous to their way of reading email.
From the comp210 web page, follow the link "The Newsgroup". This opens a separate Netscape window, with two panes: the list of articles/threads in current newsgroup (upper), and the current article itself (lower).
Articles are organized into threads -- any reply to an article is in the same thread. By default, Netscape shows you the title of the first article in each thread. Clicking on the little plus sign next to a title will expand the thread to show you its replies. By default, newer threads are toward the bottom.
Articles are marked as to whether you have read them or not. Unread articles' headings are highlighted in bold.
Click on an article's title to read it, or use the Next button to go to the next unread article. You can toggle the already-read status of an individual article by clicking on the appropriate dot in the column under the green dot.
You will want to "subscribe" to this newsgroup so that it always appears in the pulldown menu under the big row of buttons. Pull down that menu to "news.rice.edu", wait a while for a large list to appear in a new window, click the plus sign next to "rice.", then the one next to "rice.owlnews.", select "rice.owlnews.comp210", and select Join.
If you're like me, you'll hate some of Netscape's defaults. In the View menu, under Messages, select New if you only want to see the messages you haven't read before. In the View menu, under Expand/Collapse, select Expand All if you want to see the titles of all messages (not just the first) in the threads. There are lots of other options you can play with.
To post your own message to a newsgroup, you must be in the newsgroup. Then use either the New Msg or Reply button, as appropriate. You'll be put inside an editor to compose and send the message.
Note that under the File menu of Netscape's News window, Close just closes the News window only, while Exit actually means exiting all Netscape windows.
Always "log out" when you are done and leaving. Otherwise, someone can use your account, e.g., to copy or delete your assignments. One way is to type logout in the "console window" which is labeled. You do not need to exit any other programs first, but be sure to save any important changes first.