Re:Generating code from natural language is closer than you ...
by aaronblohowiak on Wednesday November 17, 2010 @12:22AM
(#1913027)
Do rules need to be global in scope?
Re:Generating code from natural language is closer than you ...
by silentbicycle on Wednesday November 17, 2010 @12:27AM
(#1913035)
Not necessarily. Some Prolog implementations have module/packaging systems, some don't. Prolog is a weird language - many details feel very antiquated* , yet on the whole it's way ahead of its time (esp. constraint programming). I think it would fare much better as an embedded library (like e.g. Lua or SQLite), rather than a freestanding language. Working on it, though I will likely finish other projects first.
* Case in point: Loading a file is "consult"; I assume this is historically because Prolog was originally a language for doing NLP in French. (See e.g. HoPL-2.)
Inform is an exapmple of a natural-language-ish, rule-based system (for programming text adventures), that could efficiently re-declare rules in a REPL (if not for its basis in virtual machine image formats that expect to be compiled from complete specifications.) Inform guarantees efficiency by using a hub-and-spoke system of rules: rather than every rule having the possibility to interact with every other rule, rules can only interact with rules in their own "rulebook" (module), the core rulebooks (standard library), and the "meta" rulebook (monkeypatches to re-specify libraries.) Thus, integrating a new definition only takes O(k + n + e) time—where k, n, and e should all be small—rather than O(n^2). This works well for Inform, but I'm not sure whether it would be as effective in a general-purpose programming environment.