Skip to content

evaluator: Add builtin sleep#66

Merged
juliaogris merged 1 commit intomasterfrom
sleep
Feb 5, 2023
Merged

evaluator: Add builtin sleep#66
juliaogris merged 1 commit intomasterfrom
sleep

Conversation

@juliaogris
Copy link
Member

@juliaogris juliaogris commented Feb 4, 2023

Add the builtin sleep function: sleep 1 sleeps for one second,
sleep 0.001 sleeps for one milli second. Now that we have wasm
hoisted on the main() go function we can just map to Go's sleep
function which panic'ed before.

evy

@github-actions
Copy link

github-actions bot commented Feb 4, 2023

firebase-deployment: https://evy-lang--66-r6m7pvp5.web.app (e359817)

@juliaogris juliaogris requested a review from camh- February 5, 2023 02:05
@juliaogris juliaogris changed the title WIP: sleeping evaluator: Add builtin sleep Feb 5, 2023
@camh-
Copy link
Member

camh- commented Feb 5, 2023

for i := range 10 90
  color "white"
  move 0 0
  rect 100 100
  color "red"
  move i 10
  circle 10
  sleep 0.01
end

for i := range 10 90
  color "white"
  move 0 0
  rect 100 100
  color "red"
  move 90 i
  circle 10
  sleep 0.01
end

for i := range 90 10 -1
  color "white"
  move 0 0
  rect 100 100
  color "red"
  move i 90
  circle 10
  sleep 0.01
end

for i := range 90 10 -1
  color "white"
  move 0 0
  rect 100 100
  color "red"
  move 10 i
  circle 10
  sleep 0.01
end

Add the builtin sleep function: sleep 1 sleeps for one second,
sleep 0.001 sleeps for one milli second. Now that we have wasm
hoisted on the main() go function we can just map to Go's sleep
function which panic'ed before.

Move the JS go wasm runtime environment to be a global, otherwise
animations from previous runs would interleave with current execution.
Copy link
Member

@camh- camh- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥦 LGTM

@juliaogris juliaogris merged commit 02dc065 into master Feb 5, 2023
@juliaogris juliaogris deleted the sleep branch February 5, 2023 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants