lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


You can obviously represent a flow diagram by having a label for
each node and a goto statement for each transition. Alternatively
replace each 

   :: node :: 
   ..........

by

   node = function ( ) ..........  end

and replace each

   goto node

by

   return node

followed finally by

   local go = function (f) while f do f = f ( ) end end
   go (start_node)

This gives an uniform way of removing gotos. But how much more
expensive is it? Its advantage is that you can easily modify go
to make traces of which nodes are visited, do statistics etc.

-- 
Gavin Wraith (gavin@wra1th.plus.com)
Home page: http://www.wra1th.plus.com/