CS 2360 Fall 95 (lab 01v.03)

alex@cc.gatech.edu (Section A)
lyman@cc.gatech.edu (Section B)


Announcements

You should read the class newsgroup at least every other day if not every day. Once the assignments start to be issued the number of posts per day will probably increase significantly.


Today's Topics

The topics to be covered today are:

The objective of this lab is to for you to gain some experience using the tools that will be used for the remainder of the quarter.

Prerequisites

Today's Lab assumes almost nothing about what you know. It does presume the ability to read and familiarity with a computer. In general, each lab will presume that the Labs and Lectures that proceeded it have been incorporated into the knowledge base in your head.


Introduction

The labs in this class serve two primary purposes. One, it is a time where you can enhance your "tool" using skills under the guidance of your friendly TA. Second, some material from lecture may enhanced by you doing some "practical" examples at the keyboard. Additionally, the labs might contain insights on concepts that, when mastered, will simplify your assignments.

Part of the "fun" of Lisp is that its implementations come with environments that are conducive to an exploratory approach to learning. You are strongly encouraged to explore outside of lab. The advantage of exploring in lab is that your friendly TA (and your classmates) are close by to help, if you need it.

Each lab will usually have a portion that is to be turned in (otherwise your attendance will count for the "credit".). The goal is to give you exercises that can be completed in the hour and a half. Sometimes we'll be successful in that objective and sometimes not. If you find yourself spending 3 hours doing this stuff then you should probably seek help. Additionally, some labs may have extra material for your enjoyment.

Collaboration in the labs is encourage. Just so long as each person does their own write-up and code writing. You may ask your TA or classmates to explain a concept. You may ask them to explain how to perform some operation with a tool. However, should not copy your classmates code and remark it as your own. [NOTE: for assignments you should avoid if at all possible looking at another person's code. Discuss things, draw pictures, perhaps write non-problem specific code fragments.]

At the beginning of every lab your TA will take roll. If you arrive late to lab make sure you get checked off before the lab session ends.

The labs should show up on the Web either on Tuesday or Wednesday morning... depending on when your TA gets done with it.

The labs are designed to be finished in 1.5 hours (plus or minus an hour). Why such a loose bound? One, because if you have mastered the material the that lab covers then it will take less time. If you are having trouble with topic/concept then it will take more time. There is no way to compensate for the cognitive variability that fifty plus students represent. If you pull an all-nighter and show up in lab dazed and sleepy then it will take longer. If you only write Lisp code once a week (in the last hours before the assignment is due) then it will take longer. However, if you find yourself spending longer than 3 hours on a lab, stop! Email your TA and get help. Or take a break, get some sleep, and then come back fresh. In essence, the objective is for you to complete the labwork within time allotted to lab.

The final page of this lab contains a questionnaire. After completing the lab, tear off that page and hand it in. [Normally, specifications for what to handing for Lab will appear in the Announcements Section on the first page.]

In general files for the labs will appear in the ~cs2360/public/labs directory on the PRISM filesystem.


Macintosh Introduction

The labs for this class utilize an Common Lisp Implementation that runs on the Macintosh. If you are not familiar with the Macintosh this section will serve as your 2 minute introduction. It assumes that you have worked with some sort of Graphical User Interface before. What is covered here is some the Macintosh terminology and ways of doing things.

You have to log into the OIT Macintoshes. If it is turned off simply press the key on the keyboard that looks like a triangle that points to the left. (on the extended keyboards it is on the upper right corner).

The background that fills the initial screen is called the Desktop. Files are stored on "Volumes". Volumes appear on the right hand side of the Desktop. In the lab your Desktop should have three volumes after start-up. The topmost represents the hardrive of the machine. Next probably comes what I call your "GT Volume". It is a volume that is for storing your files in. It appears in whatever Macintosh cluster you use on campus. The last volume is the Cluster's Server's Volume. All the applications you'll want to run will be located on this volume.

[Unfortunately, your GT Volume has noting to do with your PRISM account visible from an OIT Unix machine. So don't expect to see your files in there.]

You can open Volumes and Folders (folders are like directories) by double clicking on them.

Only one window at a time is the active window. That window will have a "filled in" title bar. To make another window active you much click on that window or its title bar.

At this point open your GT volume. Add a folder to that volume called 2360. [Choose: New Folder (from the File Menu). While it is still highlighted just type in the new name. Otherwise, click on the text "Untitled" (which should Highlight that text) and type in the new name.]

[In the future there may be some code that we hand out that will look for files in that directory/folder so it is important it be named 2360 not cs2360 or some other name.]

To remove a floppy disk from the drive you may select "Put Away" from the File Menu. The alternative is to drag the Disk's Volume Icon into the trash can. You should not just eject the disk and then turn off the machine or walk away. Make sure the disk icon disappears from the Desktop before you walk away.

[I think all of the OIT Macintoshes have Disk Exchange you can insert PC disks into them and they become "readable" / "writable".]

You can run multiple programs at one time on the Macintosh. The icon of the program in the "foreground" at the moment appears on the right hand side of the menu bar. That is also a menu of all the applications currently running. (The Finder's, the program that presents the Desktop, icon looks like the old Mac Plus box).

To turn off the Macintosh simply go to the Special menu and select Shutdown. If there is someone else who will be using the Macintosh right after you can select Restart.

Well that's your introduction to the Macintosh now on to some programs.


File Transfer

Your labs will often involve you modifying a some Lisp code. The code will be located on the Prism File system. Therefore, the first thing we're going to cover is how to transfer files to and from a Macintosh. There are two programs you can use to do this. One is called Fetch and the other is called NCSA Telnet (we'll cover the latter later in lab).

The server volume is a icon on the right hand side of the Desktop. It has the same name as the cluster you are sitting in. Double-click on that volume icon to open it. On the server volume you will find a folder called Communications. Open that folder by double-clicking on it. Inside you will find another folder label Fetch. Double-click on it and then Double-click on the Fetch application.

Open a connection to acmex.gatech.edu. Enter you username and password where directed and enter ~cs2360/public/labs as the location to open to.

You should save the file as text (click the text button) and transfer the file named init.lisp to your Macintosh by pressing the "Get File" button.

When asked where to save it, save the file to your GT volume. It is labeled with your gt-number. [Click on the "Desktop" button of the File Dialog Box to see the volumes mounted on your Macintosh.] save the file under the name init.txt. [ Why a different name... see NOTE below and later on we'll save a copy of this file as init.lisp. ]

You can transfer files back to your Prism account by pressing the "Put File" button. [You cannot put files into the ~cs2360/public/labs directory, though. Try one of your directories after lab.]

[NOTE: one of the annoying default preferences of Fetch is that it automatically word wraps lines longer than 72 characters. You can set this to a longer width by choosing the Customize Menu and the Preferences Item. Then Choose the Uploading "pop up" topic. For the length enter some large number less than 255. This is only as permanent up until someone changes it. The second most annoying default is that downloaded text files are automatically marked as being Microsoft Word documents.]


Starting MCL

The sever volume also contains Macintosh Common Lisp (MCL). It is located in the Languages Folder. Double-click on the "MCL 2.0" icon.

It is going to take a while to load up since everyone in the class is trying to access the same file at the same time. [HINT: if you know that you will be sitting down for a long session with MCL you might try copying the MCL folder to you hard disk and deleting it when you are done. Do NOT do this now!]

Later in lab I'll show a slight short-cut in getting MCL started.

[NOTE: MCL 2.0.1 will only run on the PowerMacs with the Modern Memory Manager and Virtual Memory turned off, just in case you're ever in a lab equipped with PowerMac. Additionally, MCL is not native so don't expect any speedup by using a PowerMac. For example a PowerMac7100 is probably around 30% slower at running MCL then a Quadra 700. The version currently being served up by OIT is 2.0 (except in the Library Cluster). If you are going to try to run MCL on your personal machine send me, Lyman, email and I'll tell you how to patch your 2.0 MCL to 2.0.1. Later in the Quater we hope to make MCL 3.0.1 available.]


Listener and Fred Window

MCL has a built in editor. The editor is called Fred (Fred Resembles Emacs Deliberately). If you are mouse adversive, you can use emacs cursor movement keyboard commands to move the cursor around. You have to use the mouse to move from window to window though. Every text entry window that you open will be a Fred Window. One very special Fred Window is always on the screen. It is called the Listener Window.

The Listener window is where you and MCL will talk with each other. All windows in MCL have a "mini-buffer" in the lower left corner. Sometimes information will be displayed there as you enter text (when typing to the Listener) or enter a command.

On the Macintoshes with a keyboard with a control key (all the new ones.). The control (Ctlr) key is labeled. The Option key is the "Meta" key. And the "Propeller" key is the Command Key. You use the Command Key to invoke commands from the Menu bar. The Ctlr and Meta (and shift) keys are used to issue Fred Commands.

The default prompt in the Listener Window is the question mark, `?'. Type the following lisp code into the Listener. Type a return at the end of line. MCL will answer back with the value of the expression you enter.

         "Hello World"
         (+ 2360 30)
If BillG made 4,000,000,000 dollars this year, how much will he make if his income doubles next year.

         (* 4000000000 2)
And doubles again. Type Ctlr-Meta-Shift-P. Then hit Return. This will copy that previous expression down to the last line. Wrap another multiply around it.

         (* (* 4000000000 2) 2) 
try that last one in `C'. ;-) Lisp can use arbitrary length integers. [Alternatively, you could have placed the cursor using the mouse.]

Here are a few more expressions (you can type a return to move to the next line if you haven't completed an expression nothing will be evaluated until you complete the whole thing).

         (/ 2 3)
         (*  ( / 1 4 )
              4 )
         (* 0.25  4 )
       
Now let's open a regular Fred Window. Go to the File Menu and select "Open". In the File Dialog box press the "Desktop" button, open you GT volume, and then open the file init.txt that you downloaded earlier. You'll be making a slight modification to this file later, but for now let's talk about the rest of the Commands available on the Menu bar.


Helpful Tools (and other fun on the Menubar)

File Menu

This Menu contains the usual File Menu stuff. Two commands are relatively unique to MCL. The first is the Revert command. This allows you to revert any buffer to its "original" state that is still on disk. [Remember to save periodically as you incrementally get your code working]. The second interesting commands is the "Save Copy As" command. This command will save a copy of the present buffer. It will automagically come up with a new unique name for the new file. This way you can Revert later if you wish.

Edit Menu

Your standard Edit Menu stuff here. The search facility at the bottom of the menu is different from the emacs incremental search facility you can invoke in the Fred windows with Ctlr-s

Eval Menu.

"Eval Selection" evaluates the current selection in the top editor window. If there is no selection and the insertion point is next to a parenthesis, the expression bounded by the parentheses is evaluated.

"Eval Buffer" evaluates the entire contents of the top editor buffer.

"Load..." allows you to select a file to be loaded into MCL If there is some file which you don't wish to edit, but needs to be evaluated, loading is the approach you should take.

"Abort" Cancels the current computation and returns to the read-eval-print loop.

[Try the following:

         ( + foo bar )
You have now fallen into the debugger. Notice that the prompt is not the question mark any more. It is a number followed by the "greater than". Select "Abort" from the menu (or type Command-.). As you make mistakes either handle them or abort. Don't allow yourself to be typing at error level 27 or some such large number. The good/bad thing about the debugger prompt is that you can do everything you can do at the normal Listener prompt.]

"Break" interrupts the current calculation and enters the break loop (the "debugger"). If you think you code has gone into an infinite loop this option comes in handy.

Tools Menu

There are several useful tools on the Tools Menu. I'm only going to cove two here:

Documentation Tool

The documentation tool allows you to look up documentation on the multitude of functions, special forms, etc. provided by Common Lisp on line. Although not as detail descriptions as in Steele. They will do when Steele is not handy.

Example. Select the Tool and look up the documentation on "cons", "+", and "defun".

Apropos Tool

If you don't know the exact name of the function/symbol you are looking the apropos tool is more appropriate. It allows you to choose from all the symbols that contain the substring that you enter.

Example. Select the Tool and look up the apropos on "def".

Others

Among the others are the "List Definitions" which will present all the definitions in the top level window (in buffer or alphabetical order). And "Backtrace" which will allow you to look at the stack (this is only enabled when you drop into the debugger. We'll talk about Backtrace in a later lab.).

You may also open two windows that contain all the Fred and Listener Commands.

Finally there is the "Environment..." item on the Tools menu. This brings up a dialog box that allows the you to set the values of several global variables that affect the programming environment. From time to time you might need to change these.

Windows Menu

Contains a menu of all the open windows. Any Fred window with a "dagger" next to its name has been modified.


Editing a File

Bring the "init.lisp" buffer window to the top. Type Ctlr-s and then four X's. This should bring to a spot in the file that looks like:

         (defconstant  *student-gtnum*  'gtXXXXX 
         ...
               '( ("**;*.*.*"   "gtXXXXX:2360:**:*.*.*"  )))
Replace the XXXX with your proper gt-number. Then choose "Save AS..." to save this file on your gtXXXX volume. (That is where it should have been in the first place). Save the file under the name init.lisp.

Then Quit MCL.

If the MCL folder is open on the desktop, you may now "Double- Click" on your init file to start MCL. Open the gtXXXX volume and do that. Once MCL has finished opening. Make sure the "init.lisp" Window is on top and then select "Eval Buffer" from the Eval menu. You should do open and evaluate (or simply load) this file every time you start up MCL in the Lab. [Due to weirdness of the OIT server you have to have the MCL folder open. If you have MCL on a harddisk in a normal set-up you could just double click and the Macintosh would "find" the application. For whatever reason the lab Macintoshes don't search the server for Applications.]

NOTE: you can delete the file init.txt at this point. The file init.lisp should appear with an icon that looks like a piece of coral. Double clicking on any file with such an icon will start MCL.

If you have MCL open you can, in the Finder, just double click on any MCL file to open it in the application.


Mosaic, Netscape, and Lynx

And now for something completely different.....

On the lab server Mosaic resides inside of the Communications folder. There you will see a folder for Mosaic 1.0.3. This version of Mosaic is more than a bit long in the tooth. Don't use it unless you really want to. There is a better Web surfing browser named Netscape. The Netscape fold is also in the Communications folder. Double click on the Netscape icon to get things started. (Both Browsers also run under Windows and on most of the Unix-boxes scattered around campus).

Before we do anything we should answer the question "What is a URL?". URL stands for Uniform Resource Locator. The format for a URL is

         protocol :// machine name / path and page
The following example:

         http://www.cc.gatech.edu/
is the URL for the College of Computing's Home Page. The http means to connect to the designated machine using the http protocol. If you wanted to connect with the ftp protocol you would say "ftp://....". [NOTE: www.cc.gatech.edu does not accept ftp connections.]

We are going to define some Bookmarks so that you can navigate to the class pages faster through a menu. Go the Bookmark menu and choose the "Add Bookmark" Item. At this point whatever page your are viewing is added to you Bookmarks. If you go back to the menu you should see the title of this page at the end of your list.

Now select "Open" button from the control panel at the top of the window. (this is same as selecting "Open Location "from the File menu) In the dialog box enter the URL for the College of Computing's home page and press return. Once the CoC's home page shows up find the "WWW Experimental Classes" link (scroll down the page a bit). Click on that link. Next click on the 2360 Home Page link. [If the class isn't listed yet you can use the LONG name from the syllabus

http://www.cc.gatech.edu/computing/classes/cs2360/

Once you get to the class' homepage choose save bookmark again.

Now Choose the "View BookMarks" item from the Bookmark menu. [On a Unix box at this point press the Edit button on the dialog box that appears.] Next press the "export" button. In the file dialog box hit the "Desktop" button and open your GT volume and save the BookMark file there (e.g. save as "Lyman's Bookmarks". Feel free to use your own name though.) You may wan to remove any "random" bookmarks that might have been added by the N previous users of your Macintosh before saving. After you have saved press the Close button of the dialog box (lower left corner).

At the top of the Netscape window there is a "back arrow". Selecting this you will go back to the last page you visited (namely the WWW Classes Page at this point.). You may also navigate using any of the items in the Go menu (which includes Back and Forward).

At this point you may browse around a bit. When you've sort of gotten the feel of things,. Quit Netscape.

NOTE: you can now start Netscape by double clicking on your Bookmark.

[Mosaic uses "HotLists" instead of bookmarks. And the above process is a little more quirky.]

Telnet and Lynx

We're now going to use Telnet to invoke a text only Web browser called Lynx. [Earlier I mentioned another way to transfer files to and from the Macintosh using NCSA Telnet. See the end of the Epilogue section on how to FTP with Telnet.]

Telnet is also located in the Communications folder of your server's volume. Start the telnet application and choose "Open Connection" from the File menu.

For session name enter acmex.gatech.edu and login to acmex.

At the prompt enter the following:

         lynx    http://www.cc.gatech.edu/
This will open up to the CoC's home page. Whereever there is a pretty picture all you will see here is the text, [Image]. To move up and down the page you use the up and down arrows. These move you from link to link on the page. If you just want to page down you can hit the space bar (like paging using the UNIX "more" program).

The right and left arrows follow and go back from links respectively.

On the CoC home page start to hit the down arrow until you arrive at the "Classes Using the World Wide Web". [This can look kind of funny because sometimes when you hit the down arrow the cursor can move horizontally to the next link. If you happen to press the right arrow prematurely, just press the left arrow to get back.]

At the "Classes" link press the right arrow. Once on the Classes page maneuver to the Winter 2360 link and again press the right arrow.

Once on the 2360 homepage press the letter `a'. Then press `d'. This will add a bookmark to this page. To see you bookmarks press `v'. [you can left arrow to get back from the bookmark page].

Back on the 2360 Homepage maneuver to the Syllabus link, but don't follow it just yet. If you type `d' now you will be given the option of saving what is on the end of that link to disk. [This is how you can download lisp code from the "Alternative Resources" page for instance.].

You can back out of saving the file by pressing the back arrow.

You can browse around a bit with Lynx until you get the feel of it.


Epilogue

This has been a minimalistic, despite the length, introduction to the tools which we will be using in lab and which you can possibly use to get your homework done. Try to spend some time typing in some examples from Wilensky's book and from lecture. Lab is to short for you to become a "wizard" by using the environment for a hour and a half every week.

Lynx is handy to use if you ever want to checkout the 2360 Web pages while dialed in from home. You do loose out on the graphics though.

If you looking for a tutorial on Emacs check out the Lisp Guildhall. There is a link to it on the class homepage. Look in the "Tool Time" section and you'll find a short tutorial on using GNU Emacs and Lisp together to get a MCL-like development environment.

A web page containig directions on how to turnin assignments and general code style guidlines will appear on the class homepage by tomorrow.

Telnet and ftp

To ftp file using NCSA Telnet follow these steps. One select the "FTP Enable" item under the File menu. Next choose the "Set FTP Directory..." from the File menu. With that dialog box, open your GT volume. Then then hit the "set directory" button on this dialog box. [All files will be transferred to and from that directory now.]

Next choose "Open Connections". Enter the machine's name that you want to connect to and check the "FTP session" check box. Then press return.

Once the new window opens up type "user" and a return. Then enter you username and password. You will not be given a prompt, but you can use `cd' to move through directories on the Unix box.

"get filename" will transfer a file from UNIX to the Macintosh.

"put filename" will transfer from the Macintosh to UNIX.

Type `quit' when you are done.



Questionnaire

Name:

Preferred Name (if different):

GT Number ( gtXXXXx ) :

Check the CoC Intro and Frontier Classes Completed

1501

1502

2390

2430

Check here if you followed the "old" sequence:

Lisp Knowledge coming in (where none is 0 and "I'm a Lisp wizard" is a 10)

_________

I usually work (check those that apply)

I usually edit with (check one)

My opinion of Emacs is that (check one)