dgrnbrg / piplin

Compile Clojure to FPGAs
piplin.org
93 stars 10 forks source link

Simplifying module* #45

Closed dgrnbrg closed 12 years ago

dgrnbrg commented 12 years ago

module* currently takes a bunch of thunks that are evaluated in the proper binding which do all the connections.

Connections are the only reason that modules are funky, requiring the dynamic binding context. I am beginning to doubt whether the way it's currently done is the right way, since it seems simpler to have module* take a map from port names to functions which compute their value, and then each function's arguments is a map of all the state of the module, which is easily recovered by destructuring and (I believe) supports all the necessary dynamism (and even makes it better, by moving to simple functions everywhere!)

The module macro can still support connections by doing a simple rewrite of the AST prior to generating the module* invocation, but I'm not even sure that support that kind of mixed imperative/functional style makes sense. Instead, it may be better to have a DSL for doing imperative logic programming (as long as the flow is linear w/ branching), and not worry about the current system (which is sort of a hybrid that does neither job great).