Comments (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)
- Cleanup the runtime from old / obsolete functions
- Convert XL native modules to XL_NATIVE
- Implement modules
- Error evaluation rules
- Remove remnants of bytecode interpreter (or, alternatively, fix it) HOT 5
- Fast compiler similar to what was used in Tao3D HOT 1
- Improve llvm-crap to deal with deprecated functions in LLVM 9.0.1
- Chat room? HOT 1
- [Comment/Suggestion] The Definition Operator HOT 5
- Imperative flavour: continue & break in loops HOT 4
- Add to https://github.com/kostya/benchmarks/
- NULL/nil/none/void/... value considered harmful (a "billion dollar mistake" of Tony Hoare) HOT 10
- Treat float literals as decimal float literals and not as binary float literals HOT 2
- Nubie feedback - can't build HOT 4
- Can't build native/HelloWorld HOT 3
- Basic Examples Compiler Explanation HOT 1
- Data Inheritance HOT 1
- A small scheme VM HOT 1
- Typo in opcodes.h HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xl.