Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

printing loops and if conditions #656

Open
phtj opened this issue Feb 13, 2020 · 1 comment
Open

printing loops and if conditions #656

phtj opened this issue Feb 13, 2020 · 1 comment
Assignees

Comments

@phtj
Copy link
Contributor

phtj commented Feb 13, 2020

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
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants