User loginNavigation |
archiveseval and (infinite) recursionI'm implementing an "eval" function in a scripting language... or at least contemplating it. I can envision the infinite recursion from as simple a thing as the sequence: set a to "a" if by eval I mean do variable lookup for strings, and the eval is a "deep" eval. Is one always obliged to make the eval a 1-level shallow eval? Or is eval() generally not a variable-lookup operator? I could provide a separate one, an explicitly shallow evalWithLookup() or something... more consistent macros?are there good alternatives to macros that give similar power, yet somehow manage to integrate with the non-macro language more cleanly than those of lisps? for example, in Clojure you cannot do Declarative reactive tablesA declarative reactive table is something that I've invented for building continuous compilers/interpreters: its a table whose changes are not only observable, but the statements to access and populate the table are declarative, meaning their execution order is not important. The table is populated by statements that read like "e_table[e_k] = e_v", where e_table, e_k, and e_v are expressions that are both time-dependent (e.g., they contain continuous signals). An access is simply "e_table[e_k]", where e_table and e_k are expressions that are again time-dependent, while the result is also time dependent. A declarative reactive table is then the peer of a continuous signal, its accesses can be used as signals while it is populated via signal expressions. However, these tables aren't necessarily FRP, since I don't see how the population statements could be made composable. Example: symbol tables in a continuous compiler are declarative reactive tables whose definition nodes in the AST act to populate the map while identifier reference nodes access the table. Then: // define Foo scopeA["Foo"] = FooType; // define bar in Foo FooType["bar"] = IntType; // resolve x = Foo.bar scopeB["x"] = scopeA["Foo"]["bar"] Now, when we edit the definition of "Foo" so that it becomes named "Bob", x's type will be automatically recomputed so that it now undefined (unless there is another "Foo" hiding somewhere). Since AST nodes primarily communicate through symbol tables, we get most of what we need for a continuous type checker out of declarative reactive tables. Its even possible to augment an existing compiler to use these tables (which is what I did for Scala). I'm wondering if anyone has seen a pattern like this before in a compiler implementation or perhaps another domain. I'm also wondering if I could generalize this somehow to FRP, maybe not the pure Haskell kind, but a system like FrTime or Flapjax. |
Browse archivesActive forum topics |