---

A second order virtual machine with Falcon

[ Thanks to steve
hill
for this link. ]

“Implementing commands

“So, a sequence can contain anything coming from the host
virtual machine. This includes instances of classes, where we can
easily specify the structure of a new command that we want our
virtual machine to execute.

“We can define “a command” as an item with some parameters which
does things on the virtual machine when running. Something like the
following:

class Command( pcount )
   pcount = pcount

   function run( vm )
      raise CodeError( 0,
         "You should have re-implemented 'run'" )
   end
end

“For example, we can implement the commands ‘say’ ‘copy’ and
‘remove’ that simply map to the Falcon functions I used in the
examples so far:”


Complete Story

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends, & analysis