Coder Social home page Coder Social logo

Comments (1)

c3d avatar c3d commented on May 26, 2024 1

Don't let the superficial syntax similarity fool you. XL is not evaluating things the way Prolog does, at least not by default. This is because Prolog's backtracking, while very practical and useful in some cases, is not necessarily expressive in others. I would not do heavy duty number-crunching in Prolog, for example.

It was, however, important to me to design a language that would make it possible, if not easy, to implement Prolog-style inference.

The way XL approaches the problem is to focus on the process of translation. At the root, there is a very simple parse tree, and the is operator describes how you transform the parse tree. This is why a pattern in the form Pattern is Implementation is called a rewrite. Conceptually, it rewrites code that looks like Pattern as code that looks like Implementation. This is true even for builtin operations, where the implementation will be builtin Something.

This means that if you can find a nice syntax to "tag" some specific rewrites as being Horn clauses, then you can completely control how the rewrite for these happens. We could even use the Prolog syntax for that, since it's not used in XL.

move 1,X,Y,Z :-  
    writeln "Move top disk from ", X, " to ", Y

move N,X,Y,Z :- 
    N>1                     // May backtrack here
    M = N-1 
    move M,X,Z,Y
    move 1,X,Y,0
    move M,Z,Y,X

The implementation could use automatic returns as currently envisioned for the error types, i.e. boolean value would cause backtrack / return if false.

from xl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.