3 ms·
I am confused by the first example: x = 1 t = now() print(x) at t: x = 2 Why doesn't this print `1` before `2`, and then proceed to prin
by omoikane 3y ago
I am confused by the first example:
x = 1
t = now()
print(x)
at t:
x = 2
Why doesn't this print `1` before `2`, and then proceed to print `2` in a loop (i.e. treat `at` like a `goto`)? I think there is some detail that separates declaration and definitions of the environment from the execution, but the syntax doesn't make this obvious.
- rkagerer 3y agoBecause the variable was assigned in the timeframe captured by t. It's an example of time travel to the past. The semantic is confusing at first but think of it like now() took a snapshot of your program and "at t" went back and modified it. The compiler will evaluate the entirety of your program before execution, and sequence things as directed. If you're wary this could lead to incomprehensible programs, remember: It should be understood only as an exploratory game.
- omoikane 3y agoGot it, looks like all the `at` need to be evaluated first. I think Mariposa should be added to esolangs.org