17 May 2012 sjanes71   » (Journeyer)

An idiom for nesting anonymous functions in CoffeeScript

I have some code that is very brief, but called with a timeout. It’s tiresome to name two functions just so you can call them indirectly. Anonymous functions are quite brief in CoffeeScript:

setTimeout(
    () ->
        somethingThatCalls( () -> some other work here )
    , 1000)

You probably don’t want to go too many levels here, but its convenient for short bits of code.


Syndicated 2012-04-28 14:30:40 from sj4̄nz

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!