So potentially not to different to how you might do it in Io (www.iolanguage.com):
doInReverse := 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))
)
doInReverse(
writeln("First")
writeln("Second")
writeln("Third")
)
Of course this is easy in Io because everything is just a message.
Comments
So potentially not to different to how you might do it in Io (www.iolanguage.com):
Of course this is easy in Io because everything is just a message.NB. The above code doesn't actually amend the AST but it could. Here are some previous examples of amending AST in Io posted here: http://news.ycombinator.com/item?id=1810480 http://news.ycombinator.com/item?id=1804599