index


JSL Acknowledgements

List

  1. Structure and Interpretation of Computer Programs, MIT Press, Abelson, Sussman and Sussman

  2. jsprolog by jan

Summary

JSL borrows heavily from the reference implementation of a logic programming language in section 4.4 of the SICP book. The core unification and environment management routines have been ported from Scheme to JS+JSON. The mapping was bound to be imperfect due to the separation of code and data in JS (and JSON). In any case, some features of the textbook implementation were consciously ommitted / modified :

  1. Streams : purely a schedule issue, it was easier to do an in-memory recursive implementation, using the jsProlog implementation by jan as a starting point.

  2. List processing using the dot(.) operator : a parseList callback is provided instead, along with other wrappers to native JS Array and Object processing facilities.

  3. Unification is based on object containment instead of equality. Thus, { $bind : ['$obj1', '$obj2'] } succeeds if obj2 is contained within obj1, but not the other way round. This has implications upon the core unification and environment management algorithms. The feature was needed to support most practical examples of data binding and extraction using json data.