Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Wonderful example of what macros can do.

Just for shit & giggles I'd thought I give it a go in Io (http://www.iolanguage.com):

    executeInReverse := method (
        m     := call argAt(0)
        stmts := list()              // list of statements (ie. messages)
    
        loop (
            rest := m next           // rest of messages after current 
            stmts append(m setNext)  // get current message
            m := rest
            if (m == nil, break)     // exhausted statements when "nil"
        )

        stmts reverseForeach (n, doMessage(n))
    )

    executeInReverse( writeln("Hi") writeln("Middle") writeln("Bye") )
And I think with a bit more work I can get it to amend its AST rather than rerunning the loop each time it sees executeInReverse.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: