Skip to main content

Class 10: Side Effects: Output and Input

Held: Tuesday, 7 February 2017

We consider simple textual interactive programs, programs that read input from the user and produce output.

Preliminaries

Overview

  • Simple output in Scheme
  • Using output to trace program behavior
  • Reading lines of text with read-line
  • Reading Scheme values with read
  • Side effects

Updates

News / Etc.

  • Continue partners and positions!
  • Exam 1 will be distributed on Wednesday.
  • I really do think that you are best served by working in the CS labs; you have people to help you and talk to. However, if you want to work on your own, it doesn’t work to download DrRacket (unless you run Linux). You either need to download a virtual machine (more on that soon) or connect remotely to MathLAN. You can find information under Reference -> Remote.
  • Remember: If you want to look at the eboard “in progress”, replace the .html at the end with .md.

Reminders

  • I’m always happy to (try to) answer questions via email. There is no need to apologize when sending me questions. If I take too long to answer, send another email (or even text, if it’s a reasonable hour).
  • I’m always happy to see students during my office hours. I prefer that you book me at https://rebelsky.youcanbook.me, but you can also just show up during office hours and hope that I’m not busy.
  • We have tutors available Sunday through Thursday evening from 7-10 p.m. in Science 3813/15.
  • We have mentor sessions on Wednesday and Thursday evenings from 8:00-9:00 p.m. in the CS Commons. Wednesdays will be more Q&A, Thursdays will include sample quizzes.
  • I run review sessions on Thursdays at 9am in this room.
  • We have individual tutors available for those who take advantage of the above and find that it’s not enough.
  • We have office supplies in the commons. Price is free will donation.
  • Feel free to ask me to sign you up for the department mailing list.

Upcoming Work

Extra credit (Academic/Artistic)

  • CS Table, TODAY at noon, 7 Feb 2017. Something on privacy. See email.
  • Scholars Convocation, Thursday, 9 Feb 2017, 11:00 a.m., JRC 101.
  • Thursday extras, Thursday, 9 Feb 2017, 4:15 p.m., Science 3821: Something on computer graphics (visitor from UMN). Let me know if you want the email.

Extra credit (Misc)

  • Update on Admission and Financial Aid Building and Campus Landscape Projects. Wednesday, JRC 101, 11:45-1:00. Pizza!

Extra credit (Peer)

  • Saturday the 18th, Symphony Concert. 2-4 p.m. Sound painting and more! In Sebring-Lewis.
  • Friday-Saturday-Sunday, 17th-19th, Swimming and diving conference championships.
  • Track meet this Saturday.
  • Milo the Rapper and Crunchy Kids 9 p.m., Friday, Gardner.
    Be moderate in all that you do.
  • South-Asian Chai time on Friday, at 4pm, in JRC 2nd floor. Be moderate in all that you do.
  • Org fair on Thursday. Noon-1.

Good things to do

  • Read the Electronic Frontier Foundation’s Surveillance Self Defense Tips at https://ssd.eff.org/.

Output

  • Use display to print values.
  • Use newline to print a newline.

Using Output to Trace Program Behavior

  • By inserting appropriate calls to display and newline, we can better see what our program does.

Input

  • Read a line of text with read-line.
  • Read the next Scheme value with read.
  • Use these to write interactive programs.
  • We’ll revisit these again in the future as we learn more copmlicated forms of Scheme expressions.

Side Effects

  • All of these procedures are procedures with side effects - in addition to returning a value (assuming they return a value) they also change the state of the environment.
  • Procedures with side effects tend to complicate our understanding of programs and can sometimes lead to unexpected behavior.