Hi,
I could contribute, or somebody else could do it.
I am currently following another strand. Lets call
this strand "JVM foreign function Interface and Scripting".
This strand allows directly calling Java inside the same
thread without some overhead of loosly coupling the
Prolog system. The loosly coupling is seen here:
JPC Architecture
http://java-prolog-connectivity.github.io/architecture.html
Einge Specific Drivers --> Concrete Prolog Engines
But Jekejeke Prolog doesn't need this architecture.
It could directly script Java as did JavaScript with
LiveConnect, and as does Java with Nashorn now. But
I didn't invest much energy to further develop the
tight architecture.
This has changed the last weeks. Synchronically by
accident with some other systems also discovering
the benefit of tight integration. For example one
of Freges benefit over Haskell is tight integration
with Java, see also here:
Frege Day 2015: Simon Peyton Jones transcript
https://github.com/Frege/frege/wiki/Frege-Day-2015:-Simon-Peyton-Jones-transcript
So I am actually working on this tight coupling.
There is alreay some progress. For example I have
last week implemented new directives foreign_constructor/3,
foreign_setter/3, foreign_getter/3, foreign_function/3
and foreign_constant/3. They are scheduled for
the next release 1.0.9:
Foreign Predicates
http://www.jekejeke.ch/idatab/doclet/prod/en/docs/05_run/10_docu/02_reference/07_theories/06_reflect/03_foreign.html
Please feel free to use this tight integration
interface to build a loose integration interface.
You could use the tight integration interface
but more probably you will neeed the programming API,
to implement the loose interface. The programming
API will provide you abstractions such as
Interpreter and Term.
The programming API is documented here:
Programming Interface
http://www.jekejeke.ch/idatab/doclet/prod/en/docs/05_run/10_docu/03_interface/package.html
My current goal is to strengthen the tight interface
to also allow scripting. The missing piece is currently
an auto loader. But I got this already sketched, with
an accidential help of a little SWI-Prolog discussion
recently. So most probably in the upcoming release
one will be able to directly do:
1) ?- java\lang\System:out(X), java\io\PrintStream:println(X, 'abc').
2) ?- X is java\lang\Math:sin(java\lang\Math:'PI').
2) will mostlikely work in the upcoming release, since
there is no ambiguity in finding the Java methods. On
the other hand 1) is a little bit more tricky, since
println is overloaded, and we might need some heuristic
or forbid it alltogether.
The above scripint idea is based on the ISO prolog standard
module (proposal), that suggests (:)/2 as the module
operator. Plus (\)/2 to allow structured module names
which I have already introduced some months ago. I am not
sure whether Frege also allows scripting, and whether
typed Haskell philosophy would allow it.
The nice thing about Prolog is, that there are no
types in the way, that would forbid scripting. And
also Java, although it has types, isn't in the way,
since it has an Universal Type Object and also the
primitve types can be easily wrapped if necessary.
So to sum it up:
- My current focus is JVM foreign function interface
a variant of tight coupling
(Improved in the recent weaks)
- My current focus scripting a variant
of tight coupling
(Currently in the pipeline)
- You can use the Programming interface to build
your own adapter for a loose coupling.
(Available already a couple of years, just
work through the examples in the link "Programming
Interface" above, hope they don't generate to many
errors, they are already old, but you find for
example a HTTP server side Prolog listener example)
I didn't mention some limitations of what has been
implemented so far. For example the FFI now, in
the upcoming release 1.0.9, provides dynamic
invokation. This is seen in the java\io\PrintStream:println
example. But the syntax that is used, is a static
syntax. We don't have an object receive operator
yet in Jekejeke Prolog.
So we have only a module model but not yet an object
oriented model. But my thinking recently was, who
gives a shit in an untyped language anyway? So the
whole object orientation is kind of opaque at the
moment, and hidden in the reference datatype of
Jekejek Prolog. Not yet sure when, how and whether
this will change.
So the term tight integration here is a little oversell.
It is not really a tight integration in that we
also have data types that are shared directly between
Prolog and Java. There is a slight sharing via the
Term abstraction in the Programming Interface and
via the reference datatype in Jekejeke Prolog, but it
isn't that strong. Maybe Frege is better here,
although it doesn't have scripting.
Hope this helps
Bye
rupert...@googlemail.com schrieb: