Robert Feldt wrote:
> I'm playing around with different designs to implement VM's (in a
> functional style). Think for parsing, FSM etc.
>
> One of the simpler I've come up with uses normal clojure funcs for
> each instruction to the vm. They all take the state as a map as input
> and then additional arguments. They all return the delta for the
> state. The delta is then merged into the main state in a reduce. A
> program for the VM is a collection of instructions where a keyword
> names the func. In code:
>
>
> Any comments on this? Are there better/standard Lisp/Clojure ways of
> implementing VMs? Feels clunky to have to use map accessors all over
> and to return delta state.
Well, the "classical" functional way of writing a language 
implementation is to use continuation passing style.
Since you always pass one the new state to the waiting continuation you 
never need to keep any explicit state around.

Cheers

-- 
 Ola Bini (http://olabini.com) 
 JRuby Core Developer
 Developer, ThoughtWorks Studios (http://studios.thoughtworks.com)
 Practical JRuby on Rails (http://apress.com/book/view/9781590598818)

 "Yields falsehood when quined" yields falsehood when quined.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to