-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Future erlog implementation #18
Comments
Eh, I removed server interface, as I thought it is useless, but zkessin convinced me to return it back)
|
Right now I have a bunch of quickcheck properties that use the server interface, those can be converted over to use the function interface if needed (and I probably will) In addition I am working on an external project https://github.com/zkessin/erlog-server which will let you take a prolog file and build a custom gen_server around it. That way you can take a prolog file and define what it exposes to erlang and it will be compiled into a beam file that will work like any other erlang gen_server but will be running prolog internally. It is still in early phases at this point |
I will seriously start working on it after the the OSCON conference for which I am preparing a talk + demo. It won't contain erlog, though it could, but ny Lua implementation instead. Then we can discuss details. |
I can't understand. You will leave functional interface, but remove server interface? |
I think we should view the function interface as a low level building block, which may be best used to create other more specific ways of interacting with erlog. On top of that we can then create a basic gen_server, specific servers that map to prolog code, event handlers or whatever we want. |
Function interface is awful for developing, debugging and support. If you decide so - I have to make my own branch, as I don't take this function code to our production systems. |
It is a clunky interface, but it has the advantage of being able to be easily embeded in something else. I don't plan to use it directly but to use it as a building block of a much higher level system. |
I think the idea is that we will create several high level interfaces that can serve different uses. I would not want to use the function interface directly at the REPL, but if I am embeding erlog in webmachine it would probably be idea |
OK, here are my thoughts on the "new" erlog interface as they stand so far. Valery when you mention the "functional interface" if you mean the interface through funs then it is going. I never liked it much myself and I only added it as I had two interfaces in the same module and this was the easiest way to keep them apart without having too long names. The new interface is NOT backwards compatible with the existing one. The call API is very basic and only contains what is really necessary. The idea is that users can create their own more specific interfaces on top of this when necessary. There is also no predefined server interface. The rationale for this is that it is very difficult to reach some form of accord how these types of interfaces should look. We are not in agreement. :-) So I will provide tools rather than solutions. The interface is in two parts, the main calls into the erlog engine and the database interface. The module erlog contains the calls to the engine:
This loads in an erlang module containing erlog procedures, both interpreted and compiled through a defined interface into the database.
This allows changing both the DbRef and the DbModule name on the fly. It cannot be done while stepping over solutions, the call context is lost. I am not certain about the consult/reconsult calls but I see no better way to load in files written in prolog. The The database is accessed through the
Called when the erlog state is initialised.
The Anyway these are my ideas as they stand now. |
Please see my erlog interfase in develop branch, as I came to a conclusion, that it is optimal. For your question - DbRef is a Pid of dbserver and should be the first argument, as it is maid in otp. |
I use get_db and set_db in the erlog-server code I am working on. I create an erlog instance load some stuff into it and then export the DB and actually put it in a beam file to be re-hydrated later. So that you can start erlog in a known state. In short it lets me include a prolog file into a beam file |
I like @rvirding 's comments above. The question is do we want to make it a fun that returns a new fun or maybe we want to make it a tuple module so it will return {erlog, State} If its a PID we should have some standard protocol which a process can implement to work with it I think. |
Seeing we both want a server based interface and a purely local interface I think it is better that the base system provide the local interface, and at a basic level. With that it is not difficult to build a server based interface when necessary, or have a different interface.
The load interface is for loading libraries written in erlang like There is a The Note that the database reference is opaque to the interpreter, it uses the API in the database module to access it. |
If you want to fill database and than move them to another system - just don't use ets or dict. I made behaviour callbacks for this purpose. Try dets or sqlite/h2. |
Why not use dict? it would seem an ideal pure functional data structure if you want to export it, esp if you want to embed that data in a larger file. |
Using dict will be the default if you just call |
Should the database interface given in DbModule actually generate errors using the calls in erlog_int, or should it just return an error value, |
I like the return |
So do I so I will probably go with that. It will also make the database implementation modules easier to write. Though they will still have to follow the rules for what is illegal, for example if a functor had been declared a built-in you can't add clauses to it or make it compiled. |
OK I have now pushed a first version of the new erlog interface in the branch
Note that this is still experimental but it is very much the way I want to go. |
Forgot to mention one thing that definitely will be coming and that is more properties of procedures, for example of whether they are dynamic or not. |
I am going to merge this into my testing branch to make everything pass (today or tomorrow if I have time) I was planning to add some IO predicates to match SWI Prolog's as much as possible |
OK but take it slowly as things may change as we test it. I am going to try I was planning to follow the i/o procedures in standard prolog but they Take it slowly until this reaches the develop branch. From my Nexus
|
Fixing the tests was pretty easy, it was mostly just refactor to the New API, none of them look at the internals |
All that I see is left to do is to add a property list to procedures in the DB and modify code to test for them. For example 'dynamic'. |
There has been some discussion on how to develop erlog. Two issues have arisen:
My views on these are:
Erlog should only contain a basic local functional interface and no server interface. Users can write their own servers when necessary and choose which interface they want/need. The erlog interface should work at the erlang data level; users can build other interfaces on top of this, for example using the erlog parser to build a string interface.
The database interface should be abstracted out of the interpreter. My current idea is that there is a predefined function interface to the database and when you start the interpreter you give the name of the callback module to access the database. This would work in much the same way as OTP behaviours. This would allow using dict (the default) or ETS directly, or in a server, or a more complex system where different types of procedures are stored in different ways.
My reason for keeping both interfaces very basic is to make it easier for users to plug in specific code. There is no way that erlog can cater to all the different ways users may want to interface it so I feel it is better to keep it basic and provide support to extend it. Hopefully by keeping it basic we can make something everyone can use and specialise for their own needs.
(Should we have the discussion in the mailing list instead?)
The text was updated successfully, but these errors were encountered: