This page is no longer maintained — Please continue to the home page at www.scala-lang.org

another continuations question

2 replies
Ian Clarke
Joined: 2008-12-18,
User offline. Last seen 42 years 45 weeks ago.

I'm getting the following error:

src/swarm/collections/TreeMap.scala:18: error: then and else parts
must both be cps code or neither of them
if (k == key) {
^
one error found

You can see the source file here:

http://github.com/sanity/Swarm/blob/ed5ba078dbc4d38b9de6a944b24e1c7c564d...

I'm not sure I understand the problem. Why must both sides of the if
be cps code? How can I solve it?

Thanks,

Ian.

Tiark Rompf
Joined: 2009-02-18,
User offline. Last seen 42 years 45 weeks ago.
Re: another continuations question

Try omitting the explicit return and just use Some(value) in the then
part. If that doesn't work, use shiftUnit(Some(value)).

The reason that both then and else part must be cps expressions is
that for the selective cps transformation, it must be known whether
the result of the conditional is a regular value or a ControlContext
object (every cps expression is transformed to such an object), which
can be further composed. In many cases a shiftUnit, which lifts a
regular value to a cps value is inserted automatically.

- Tiark

On 06.09.2009, at 22:30, Ian Clarke wrote:

> I'm getting the following error:
>
> src/swarm/collections/TreeMap.scala:18: error: then and else parts
> must both be cps code or neither of them
> if (k == key) {
> ^
> one error found
>
> You can see the source file here:
>
> http://github.com/sanity/Swarm/blob/ed5ba078dbc4d38b9de6a944b24e1c7c564d...
>
> I'm not sure I understand the problem. Why must both sides of the if
> be cps code? How can I solve it?
>
> Thanks,
>
> Ian.
>

Ian Clarke
Joined: 2008-12-18,
User offline. Last seen 42 years 45 weeks ago.
Re: another continuations question

On Sun, Sep 6, 2009 at 3:42 PM, Tiark Rompf wrote:
> Try omitting the explicit return and just use Some(value) in the then part.
> If that doesn't work, use shiftUnit(Some(value)).

Ah, omitting the "return" did the trick - thanks for the quick response!

Ian.

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland