Yield PrologDownloadDocumentation News Query Editor Benchmarks Report Bugs Sourceforge Project |
Yield
Prolog lets you embed
Prolog programs directly in Python, C# [1]
or Javascript [2]
by using the yield
keyword. For example,
here is the classic "uncle" predicate in Prolog:
(This says that a person has an uncle if the person has a parent and that parent has a brother.) And here it is from the Yield Prolog compiler:
As you can see, the flow of the code in Yield Prolog is similar to Prolog. The Tutorial explains how these examples work, without expecting you to know Prolog. And the benchmarks show that Yield Prolog in C# can be faster than efficient Prolog systems like Yap Prolog and XSB. Yield Prolog is made possible by the yield keyword, which automatically creates iterators that you can nest, combined with Yield Prolog's Variable class which can unify a variable with other values (just like in Prolog). There is no "API" standing between your code and Yield Prolog, because you just use the yield keyword to make "iterator functions" wherever you need them. Yield Prolog is part of your code, which can mix Prolog-style predicates directly with ordinary arrays, file I/O, GUI calls and all your own classes. Because it lets you mix these, Yield Prolog unifies the declarative and procedural programming models. 1. Tested with C# .NET 2008+ and Mono 2.0+. 2. Yield Prolog for Javascript is supported in Firefox, Seamonkey, Chrome and Edge, which fully support the yield keyword. |