Skip to content

Instantly share code, notes, and snippets.

@tafsiri
Created January 24, 2011 05:12
Show Gist options
  • Save tafsiri/792866 to your computer and use it in GitHub Desktop.
Save tafsiri/792866 to your computer and use it in GitHub Desktop.
#Actors
#this code is from day 2
Delay := Object clone
Delay send := method(
args := call message arguments
for(i,0, args size - 1, 2,
delay := doMessage(args at(i))
msg := args at(i+1)
wait(delay)
msg doInContext(call sender)
)
)
Me := Object clone
Date asString("%H:%M:%S") println
#"Hello There! the time is " ..
Me time := method(at, "Hello There! the time is " .. at asString("%H:%M:%S") println)
Me delayMsgs := method(Delay send(1, time(Date now),
3, time(Date now),
5, time(Date now)))
#note the @@ symbol is the only thing we added to this snippet of code from day 2
Me @@delayMsgs
#now the previous line returns immediately and we can do other things. In this case
#we just wait (so that we can see the output from the delay).
wait(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment