1 / 14

CS162 Week 3

CS162 Week 3. Kyle Dewey. Overview. Assignment 1 wrap-up Secure information flow tidbits Problem solving in Scala. Assignment 1. Secure Information Flow. Adding a Field for the Label. Could add in the base class Could put in each derived class

angelk
Download Presentation

CS162 Week 3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS162 Week 3 • Kyle Dewey

  2. Overview • Assignment 1 wrap-up • Secure information flow tidbits • Problem solving in Scala

  3. Assignment 1

  4. Secure Information Flow

  5. Adding a Field for the Label • Could add in the base class • Could put in each derived class • Functionally the same, but internally different

  6. pc Stack • Define an object named pc • It internally has a mutable stack • There are many ways to do this, but scala.collection.mutable.Stack is probably the easiest

  7. test27.not

  8. Any questions on secure information flow?

  9. Problem Solving in Scala

  10. Useful Scala Features

  11. Call-by-Value • Functions take in values which have already been evaluated, and act on those • Typical of most languages def foo(x: Int) = x + 5 def bar(x: Int) = 42 ... foo(12 + 3) bar(8 * 2 * 7)

  12. Call-by-Name • Functions take unevaluated expressions • Using these expressions triggers evaluation for each use def foo(x: Int) = x + 5 def bar(x: Int) = 42 ... foo(12 + 3) bar(8 * 2 * 7)

  13. Significance • In a pure language, this could affect program termination, but little else • With mutable state, it can be used to define rich control flow operators • while.scala

  14. Streams • Streams are an infinite sequence of something • Positive integers, Fibonacci sequence, prime numbers, etc. • Scala supports their use • prime_numbers.scala

More Related