design-automation / mobius-parametric-modeller

Möbius for parametric modelling.
https://design-automation.github.io/mobius-parametric-modeller/
MIT License
10 stars 6 forks source link

printing loops and if conditions #656

Open phtj opened 4 years ago

phtj commented 4 years ago

Printing should be possible for For-each, While, If, If-else, Else It should print the following messages to the console

For loops Executing For-each: i = value Executing While: condition = value

For conditionals Executing If: condition = value Executing Else-if: condition = value Executing Else

In the case of While, If, If-else, we would like to see the fact that the code-block was not executed. i.e. we would like to see that the condition evaluated to false

e.g. for an If ... Else-if ... Else statement it might print :

Executing If: condition = false
Executing Else-if: condition = false
Executing Else
...

How to print if the condition is false? The print statement would have to be inserted before the code-block This means executing the condition two times, something like this

console.log("Executing If: condition = ", condition)
if (condition) {
    ...
}

There is, of course, a danger that the condition may have a side effect, in which case clicking print might cause the procedure to have a different outcome. But for the moment, i cannot think of any side effects that are possible, given the restrictions of the mobius language.

phuongtung1 commented 4 years ago

it should be ok for most of these except for else-if. I dont think it's possible to insert a print statement between the if and else-if so that it would print out the else-if condition for all cases. i can only put it as the first statement inside else-if, so it would only print out when the condition is true