RoPi0n / mash-lang

Untyped, lightweight, crossplatform OOP language.
Other
94 stars 4 forks source link

Coroutines #6

Open pmcgee69 opened 1 year ago

pmcgee69 commented 1 year ago

Looking at your example here ... https://sudonull.com/post/32157-Mash-multithreading-coroutines-async-wait

proc main():
  cor3 ?= new TCoroutine(false, null)
  cor3 -> Execute ?= class::Proc3
  cor2 ?= new TCoroutine(false, cor3)
  cor2 -> Execute ?= class::Proc2
  cor1 ?= new TCoroutine(false, cor2)
  cor1 -> Execute ?= class::Proc1
  cor3 -> NextCoroutine ?= cor1
  cor1 -> Resume()
  InputLn()
end

Might as well have an overload TCoroutine( boolean, TCoroutine, TProc ) ... ?

proc main():
  cor3 ?= new TCoroutine(false, null, class::Proc3)
  cor2 ?= new TCoroutine(false, cor3, class::Proc2)
  cor1 ?= new TCoroutine(false, cor2, class::Proc1)
  cor3 -> NextCoroutine ?= cor1
  cor1 -> Resume()
  InputLn()
end
RoPi0n commented 1 year ago

Lol, someone translated my post's into english

RoPi0n commented 1 year ago

Yes, why not to override it. But this implementation based on threads and not a true coroutine. I wrote this project in education purposes only. @pmcgee69