dynamobi/dynamobi — Issue #847: [FRG-23] Java calc implementation of CASE is eager; should be lazy
Author: dynamobi-build
Created: 2011-12-30 03:52:28+00:00
State: open
Labels: FRG, Java Calc Codegen

[reporter="jvs", created="Mon, 23 Jan 2006 14:10:50 -0500 (GMT-05:00)"]
Case

when x < -5 then x * 2

When x < 0 then x + 10

When x < 10 when sqrt(x) + x * 2

Else sqrt(x)

End

For a negative number, we want to make sure not to evaluate sqrt(x). But the Java calc codegen currently spits out all the possible expressions needed first, and then uses a compound if/elseif/else structure to choose the right one.

We should make sure that both the predicates (x < 10) and the return values (x + 10) are only computed if all previous branches have been skipped.