CSC151.02 2013F, Class 49: File Basics
======================================

_Overview_

* Preliminaries.
    * Admin.
    * Questions on the project.
    * Questions on the exam.
* File basics: Data persistence and beyond.
* Ports.
* Basic file operations.
* Lab.

Preliminaries
-------------

### Admin

* NEW LAB PARTNERS TODAY!  Someone you haven't worked with the past two weeks.
* People who missed the merge sort class are expected to do
  lab writeup 29: Problems 6 and extra 1.
* Lab writeup 30: Files (Your Name)
    * Problem 4
* Upcoming extra credit opportunities:
    * Learning from Alumni Thursday: Erik Hanson (in person)
    * CS Extras Thursday: Multiple Models for Mediascripting (Manuella et al.)
    * CS Table Friday: TBD.
    * Swim meet Friday/Saturday.
    * Any self-care week activity.
    * _One Grinnell_ rally on December 4 at 4pm (unless you are taking photos).
        * And yes, I've sent a note to Dean Arora about the scheduling.
    * Basketball, Wednesday, maybe 5

### Questions on the Project

When is it due?

> Tuesday at 10:30 p.m.

Should we send you images?

> No.  Put them in the drop box.

How much is enough variance?

> You need to be able to argue that they are different.  Neighboring values 
need not visibly differ.  Off by 10 or more you should be able to point to 
something that I can see (or that someone who is not color deficient can see).
Off by 100 or more should be obvious.

### Questions on the Exam

Do we get a 2 point bonus for turning it in Monday night.

> Yes.

File basics: Data persistence and beyond
----------------------------------------

It's time to learn a new data type (not quite our last one).  

Files.  A collection of data that persists between executions of the program.

* What kinds of values are there?  How do we represent values?  How does Scheme
  represent values?  What do they look like?
* What procedures can we use to work with them and what parameters do they take?
* What kinds of problems do we solve with them?
* How does it differ from other data types?
* What are some limitations?
* Can we mutate them?
* How do we create them?

Two ways to think about files: input and output

We communicate with files using 'ports'

* The file plus knowledge of where in the file we are

Major procedures:

* (open-input-file "/path/to/fle") - opens the file for reading, gives you a port
* (open-output-file "/path/to/file") - Creates the file for writing, gives you a
  port.  

* (write value port)
* (display value port)
* (newline port)
* (close-output-port port)

* (read port) - returns a special value for end of file
* (read-char port) - returns a special value for end of file
* (close-input-port port)

Lab
---
