I don’t know yet how to bake it. In formerly Jekejeke--- Synchronet 3.20a-Linux NewsLink 1.114
Prolog I have ultra static but no yield or auto-yield yet,
despite that it has engines!
In Dogelog Player I have yield or auto-yield, but no
cooperative task spawning yet. One Prolog system that
has already fibers is Tau Prolog, but their system
doesn’t perform very well otherwise. SWI-Prolog is
in a good position in that it has already engines with
yield and recently auto-yield!
Mostowski Collapse schrieb am Donnerstag, 2. März 2023 um 13:06:55 UTC+1:
So is there really a 3rd category Worker Fiber? Thanks for
challenging me explaning a concept over and over again.
Q: You shouldn’t, but you need between fibers on the same worker?
A: Do you mean shared atom and clause garbage collection is needed?
Yes. But only a single threaded version of it. Its not doing anything between fibers inside the same worker. You don’t need locking or
atomics for fibers as I see it. With the JavaScript Worker model,
you land in single threaded Prolog system, although you are multi-threaded. I don’t know how difficult it would be to build a
SWI-Prolog system that has Workers running single-threaded,
but nevertheless supports many of them over threads? You possibly
have to separate the Workers from a Workers monitor. Make the
Workers monitor a separately compiled component, where multi-threading
is enable. And compile the SWI-Prolog Workers Prolog runtime system single-threaded, i.e. with multi-threading disabled.
Mostowski Collapse schrieb am Dienstag, 28. Februar 2023 um 01:05:12 UTC+1:
Multi-Threaded Prolog ----\
Single-Threaded Prolog ---+-----> Novacore
Worker Fiber Prolog ------/
Now I made a new version of my non-fibers and fibers API.--- Synchronet 3.20a-Linux NewsLink 1.114
I removed the name “engine” from the API, so as to avoid
confusion. Engines are more lower level than the Python
idea of callbacks and tasks. The API now reads:
Part 1: Callbacks (non-fibers) (Changed)
They are Stackless and run in the <strike>main Engine</strike>
current Task of the Current Thread. In my current take, they run
without Auto-Yield and without Yield-Allowed.
os_call_later(G, D, T):
The predicate succeeds in T with a new timer. As a side effect
it schedules the goal G to be executed after D milliseconds.
os_call_cancel(T):
The predicate succeeds. As a side effect it cancels the timer T.
Part 2: Tasks (1:N fibers) (Changed)
They are Stackful and create their own <strike>Engine</strike> Task
in the Current Thread. In my current take, they run with
Auto-Yield and with Yield-Allowed.
os_task_current(E):
The predicate succeeds in E with the current <strike>engine</strike> task.
os_task_abort(E, M):
The predicate succeeds. As a side effect the <strike>engine</strike>
task E gets the message M signalled.
os_task_create(G, E):
The predicate succeeds in E with a new <strike>engine</strike> task
for the goal G. The task gets immediately scheduled to be executed.
Mostowski Collapse schrieb am Donnerstag, 2. März 2023 um 13:08:48 UTC+1:
I don’t know yet how to bake it. In formerly Jekejeke
Prolog I have ultra static but no yield or auto-yield yet,
despite that it has engines!
In Dogelog Player I have yield or auto-yield, but no
cooperative task spawning yet. One Prolog system that
has already fibers is Tau Prolog, but their system
doesn’t perform very well otherwise. SWI-Prolog is
in a good position in that it has already engines with
yield and recently auto-yield!
Mostowski Collapse schrieb am Donnerstag, 2. März 2023 um 13:06:55 UTC+1:
So is there really a 3rd category Worker Fiber? Thanks for
challenging me explaning a concept over and over again.
Q: You shouldn’t, but you need between fibers on the same worker?
A: Do you mean shared atom and clause garbage collection is needed?
Yes. But only a single threaded version of it. Its not doing anything between fibers inside the same worker. You don’t need locking or
atomics for fibers as I see it. With the JavaScript Worker model,
you land in single threaded Prolog system, although you are multi-threaded. I don’t know how difficult it would be to build a
SWI-Prolog system that has Workers running single-threaded,
but nevertheless supports many of them over threads? You possibly
have to separate the Workers from a Workers monitor. Make the
Workers monitor a separately compiled component, where multi-threading is enable. And compile the SWI-Prolog Workers Prolog runtime system single-threaded, i.e. with multi-threading disabled.
Mostowski Collapse schrieb am Dienstag, 28. Februar 2023 um 01:05:12 UTC+1:
Multi-Threaded Prolog ----\
Single-Threaded Prolog ---+-----> Novacore
Worker Fiber Prolog ------/
Symbol is a built-in object whose constructor returns a symbol primitive https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SymbolIt wouldn’t match JSON usage, since the keys are not supposed
Inside Novacore we could reinvent Prolog Dicts. JavaScript--- Synchronet 3.20a-Linux NewsLink 1.114
has a primitive data type for Symbols, so you can call Symbol.for(“key”), which will internalize the string, so that
you can use pointer equality on the result:
Symbol is a built-in object whose constructor returns a symbol primitive https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol
It wouldn’t match JSON usage, since the keys are not supposed
to be Symbols, only Strings. But maybe this is only superficially,
and internally they are Symbols. One could do the same for
Novacore Prolog Dicts. On the surface Novacore Prolog
Dicts would use Strings:
?- X = {"abc" : 123.45, "def": 67}.
But under the hood there would be a transition from String to Atom:
?- X = {"abc" : 123.45, "def": 67}, X =.. L.
L = [C'novacore_dict, abc, 123.45, def, 67]
The rational would be: The keys usually form a limited vocabulary.
Interestingly with the above trick, a Prolog parser can--- Synchronet 3.20a-Linux NewsLink 1.114
recognize Novacore Prolog Dicts. Since it would see this
production at the head of a Novacore Prolog Dict:
novacore_dict :== "{" string ":" term ... "}"
Which is unlike the ISO core definition of “{}”, since in
ISO core there are no strings, and even a qualified call in
ISO module assumes that we have atom “:” term. So
there would be no collision with this production:
set :== "{" term "}"
Mostowski Collapse schrieb am Samstag, 18. März 2023 um 13:55:21 UTC+1:
Inside Novacore we could reinvent Prolog Dicts. JavaScript
has a primitive data type for Symbols, so you can call Symbol.for(“key”), which will internalize the string, so that
you can use pointer equality on the result:
Symbol is a built-in object whose constructor returns a symbol primitive https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol
It wouldn’t match JSON usage, since the keys are not supposed
to be Symbols, only Strings. But maybe this is only superficially,
and internally they are Symbols. One could do the same for
Novacore Prolog Dicts. On the surface Novacore Prolog
Dicts would use Strings:
?- X = {"abc" : 123.45, "def": 67}.
But under the hood there would be a transition from String to Atom:
?- X = {"abc" : 123.45, "def": 67}, X =.. L.
L = [C'novacore_dict, abc, 123.45, def, 67]
The rational would be: The keys usually form a limited vocabulary.
Currently I get an error when I use string keys:--- Synchronet 3.20a-Linux NewsLink 1.114
/* SWI-Prolog 9.1.4 */
?- current_prolog_flag(double_quotes, X).
X = string.
?- X = _{"abc": 123.46, "def": 67}.
ERROR: Syntax error: key_expected
Also there is the annoying need for an underscore functor.
With string keys I could directly embed JSON?
In this case null, false and true could be easily an atom.
Thats kind of solving the constant problem from another angle.
Mostowski Collapse schrieb am Samstag, 18. März 2023 um 13:56:23 UTC+1:
Interestingly with the above trick, a Prolog parser can
recognize Novacore Prolog Dicts. Since it would see this
production at the head of a Novacore Prolog Dict:
novacore_dict :== "{" string ":" term ... "}"
Which is unlike the ISO core definition of “{}”, since in
ISO core there are no strings, and even a qualified call in
ISO module assumes that we have atom “:” term. So
there would be no collision with this production:
set :== "{" term "}"
Mostowski Collapse schrieb am Samstag, 18. März 2023 um 13:55:21 UTC+1:
Inside Novacore we could reinvent Prolog Dicts. JavaScript
has a primitive data type for Symbols, so you can call Symbol.for(“key”), which will internalize the string, so that
you can use pointer equality on the result:
Symbol is a built-in object whose constructor returns a symbol primitive
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol
It wouldn’t match JSON usage, since the keys are not supposed
to be Symbols, only Strings. But maybe this is only superficially,
and internally they are Symbols. One could do the same for
Novacore Prolog Dicts. On the surface Novacore Prolog
Dicts would use Strings:
?- X = {"abc" : 123.45, "def": 67}.
But under the hood there would be a transition from String to Atom:
?- X = {"abc" : 123.45, "def": 67}, X =.. L.
L = [C'novacore_dict, abc, 123.45, def, 67]
The rational would be: The keys usually form a limited vocabulary.
Now I have already removed the following predicates from--- Synchronet 3.20a-Linux NewsLink 1.114
Novacore, they landed in library(compat):
- numbervars/2
- subsumes/2
- subsumes_term/2
Now wonder where variant/2 would land? SWI-Prolog wants to tell me
that variant/2 might need library(compat), because of numbervars/2.
Assuming A and B have already distinct variables I get the following solution:
A =@= B :-
\+ \+ (numbervars(A, 0, N),
numbervars(B, 0, N),
A == B).
https://www.swi-prolog.org/pldoc/doc_for?object=%28%3D@%3D%29/2
On the other hand this solution gives me also a library(compat)
dependency, since its based on subsumes_term/2. Again assuming A and
B have already distinct variables I get the following solution:
A =@= B :-
subsumes_term(A, B),
subsumes_term(B, A). https://www.complang.tuwien.ac.at/ulrich/iso-prolog/built-in_predicates
Isn't there something simpler?
We are now exploring file systems with novacore.
And here and then we have a couple of primitives
and then do some bootstrapping. It currently lands
in library(random) until we find a better place:
% directory_member(+Atom, -Atom)
directory_member(F, N) :-
directory_files(F, L),
member(N, L).
% ensure_directory(+Atom)
ensure_directory(F) :-
file_exists(F),
file_property(F, type(directory)),
!.
ensure_directory(F) :-
make_directory(F).
Guess what, finding semantic and support of
directory_files/2, file_exists/1 and file_property/2
is already non trivial.
LogNonsenseTalk with its brainwash is totally
useless. This here is already wrong:
file_exists(File) :-
absolute_file_name(File, ExpandedPath),
{exists_file(ExpandedPath)}.
https://github.com/LogtalkDotOrg/logtalk3/blob/master/library/os/os.lgt
Becaue for example exists_file/1 in SWI-Prolog
means exists regular file. But file_exists/1
should mean exists file of any type. Just
lookup what GNU Prolog provides. In OS lingua
file means often regular, directory, etc..
Mild Shock schrieb:
We are now exploring file systems with novacore.
And here and then we have a couple of primitives
and then do some bootstrapping. It currently lands
in library(random) until we find a better place:
% directory_member(+Atom, -Atom)
directory_member(F, N) :-
directory_files(F, L),
member(N, L).
% ensure_directory(+Atom)
ensure_directory(F) :-
file_exists(F),
file_property(F, type(directory)),
!.
ensure_directory(F) :-
make_directory(F).
Guess what, finding semantic and support of
directory_files/2, file_exists/1 and file_property/2
is already non trivial.
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 919 |
Nodes: | 10 (0 / 10) |
Uptime: | 70:30:42 |
Calls: | 12,185 |
Files: | 186,526 |
Messages: | 2,236,721 |