Seite 1 von 1

Assignment 7 Tests for Task 3

Verfasst: 11. Dez 2018 16:29
von Kabooom
Hello,

i was looking at the tests for Task 3 and i have two questions:

- Shouldn't the expression in this test evaluate to true?

Code: Alles auswählen

test("10") { assertResult(BoolV(false))
     { runInterp(And(true, BindCC('k, Or(true, App('k, false))))) }}
- Shouldn't the expression in this test evaluate to false?

Code: Alles auswählen

test("16") { assertResult(BoolV(true))
     { runInterp(And(true, BindCC('k, Let('f, Fun('v, And('v, App('k, true))), App('f, false))))) }}

Re: Assignment 7 Tests for Task 3

Verfasst: 12. Dez 2018 11:21
von mirko-koehler
Hi,

The continuations in task 3 are of type Value => Nothing. That means that these continuations never return, i.e. once the continuation is called there is no coming back!
In order to return something from a continuation, we throw an exception that contains the return value, see EndOfWorldException in the test cases. In test 10, calling the continuation should execute the rest of the program when the continuation was bound and never return, i.e. the And is executed and the continuation never returns to the Or. The same holds for test 16.

Note that this is different from "delimited continuations" that have been introduced with reset and shift in the lecture. These continuations return a value.