

My hobby: answer beginner SO question after a night out - starmole

So, sometimes when I get home too early but still keep drinking I like to answer random stuff on SO. And every now and then, there is a random question that is so wrong and clearly by somebody just starting to learn programming, that it becomes a challenge to answer it.<p>In this case: http:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;18026506&#x2F;i-need-something-similar-to-sleep-function-for-a-program-that-uses-opengl<p>I probably did a piss poor job as a teacher, but it got me thinking, how would one approach this in a functional language? I did my share of Haskell when it was still a pure academic experiment, but never really took to it.<p>So, how would a functional approach to this simple but natural problem look like?
======
arh68
There are various methods and various languages. Scheme uses continuations,
javascript can use futures/promises, sometimes you just see a 'yield'
operator. Many of these ideas are close to Tony Hoare's 'Communicating
Sequential Processes' paper/book [1], so if you want the low down, read the
paper.

[1] [http://usingcsp.com/cspbook.pdf](http://usingcsp.com/cspbook.pdf)

~~~
starmole
Thanks for the reply. I was really drunk when posting this, sorry :) I know
how things are done in different languages. The thing that stumped "drunk me"
was how much harder it would be to explain them. "sober me" realizes that my
premise was wrong. I was answering a beginner imperative question. There is no
good functional answer. A beginner functional question would be different and
have a different answer. In reading my post it is kind of funny to see my own
weird tunnel thinking - don't drink and think :).

