Seite 1 von 1

Ex. 2.4: Lazy Evaluation

Verfasst: 29. Apr 2009 17:56
von sproksch
By reading the slides I understood the difference between eager-evaluation and lazy-evaluation, but anyhow I have no idea how this task could be solved. Some "googling" provided some references to the Scheme keywords "delay" and "force", but I'm not sure if these should be used. Could someone please explain to me how to start? I'm a very unexperienced in Scheme-programming and it's still very hard for me to think the "Scheme"-way, so I would be grateful for any help provided.

Re: Ex. 2.4: Lazy Evaluation

Verfasst: 29. Apr 2009 18:23
von sewe
You don't need any more Scheme than you have seen already (procedure calls and conditionals). Also, it seems to me you are thinking about the wrong level, i.e., about the way Scheme interprets your program (delay, force, and friends). Think rather about the way your program interprets WAE. I hope this helps.

Re: Ex. 2.4: Lazy Evaluation

Verfasst: 30. Apr 2009 11:47
von Nori
I think I've implemented lazy-evaluation, but I cannot think of a test case for it.
The results of the two evaluations strategies should not differ (according to the book). The only thing I can think of, is that one strategy does not terminate. To test that I would need to define my own, recursive function, in WAE, but that is not yet possible in assigment-1.scm .

Re: Ex. 2.4: Lazy Evaluation

Verfasst: 30. Apr 2009 11:56
von Nori
got it, sorry.

Re: Ex. 2.4: Lazy Evaluation

Verfasst: 30. Apr 2009 16:53
von BastiS
In the assignment it's written "Then write a test case that succeeds when using lazy substitution, but fails with eager substitution."
Is an exception also a "fail" or do we have to have a "bad" as a result?

Re: Ex. 2.4: Lazy Evaluation

Verfasst: 30. Apr 2009 18:26
von sewe
Just an exception is fine. If you want to include a test, consider using test/exn. Note, however,that the correct, user-generated exception then generates a success, not a failure.