- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
another continuations question
Sun, 2009-09-06, 21:31
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.
Sun, 2009-09-06, 22:07
#2
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.
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.
>