Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • May 25 17:37

    pmoura on master

    Update `lgtunit` tool documenta… (compare)

  • May 24 23:06

    pmoura on master

    Fix tests for the Prolog `aboli… (compare)

  • May 24 10:49

    pmoura on master

    Additional test for the standar… (compare)

  • May 24 09:05

    pmoura on master

    Update section on known issues … (compare)

  • May 24 08:52

    pmoura on master

    Add tests for custom generators… (compare)

  • May 23 20:58

    pmoura on master

    Fix `arbitrary` library documen… (compare)

  • May 23 11:39

    pmoura on master

    Fix some spelling typos in the … (compare)

  • May 23 10:54

    pmoura on master

    Fix `diagrams` tool documentati… Update SVG diagrams (compare)

  • May 23 08:23

    pmoura on master

    Fix if-then-else linter warning… (compare)

  • May 23 08:11

    pmoura on master

    Add linter warnings for if-then… Update SVG diagrams (compare)

  • May 21 20:25

    pmoura on master

    Update `lgtunit` tool documenta… (compare)

  • May 21 15:54

    pmoura on master

    Update `lgtunit` tool documenta… (compare)

  • May 21 09:27

    pmoura on master

    Update `lgtunit` tool documenta… (compare)

  • May 21 09:02

    pmoura on master

    Update `tutor` tool for the new… Update SVG diagrams (compare)

  • May 21 08:39

    pmoura on master

    Add linter warnings for missing… (compare)

  • May 20 16:06

    pmoura on master

    Fix `lgtunit` tool QuickCheck i… Update SVG diagrams (compare)

  • May 20 14:01

    pmoura on master

    Fix `arbitrary` library categor… Update SVG diagrams (compare)

  • May 20 10:38

    pmoura on master

    Fix bug in the `arbitrary` libr… (compare)

  • May 19 19:04

    pmoura on master

    Fixes and performance improveme… Update SVG diagrams (compare)

  • May 18 13:36

    pmoura on master

    Change `diagrams` tool `omit_pa… Update SVG diagrams (compare)

Paulo Moura
@pmoura
You're not alone. Most Prolog programmers completely miss the point of interfaces/protocols.
See e.g. the 50 years of Prolog paper.
In the latest version of the paper (v3), they write:
"Interfaces Beyond modules, programming in the large can be supported by mechanisms that allow describing and enforcing separation between interfaces and implementations. Such interfaces are typically sets of signatures, specifying types and other properties, to be matched by all implementations, and thus allow stating what a given implementa- tion must meet, and making implementations interchangeable in principle. They should include at least constructs to express the external connections of a module, not only in terms of the predicates it should expose, but also the types, modes, and other character- istics of their arguments, and a compiler/interpreter capable of enforcing those interfaces at compile- or loading-time. Ciao’s assertion language, preprocessor, and interface defi- nitions offer a possible solution in this area."
Logtalk solved this problem 24 years ago... no mention.
Paulo Moura
@pmoura
People (including the authors of this paer) that claim to want portable Prolog libraries and portable Prolog developer tools but dismiss Logtalk as a solution seem to be oblivious that in order to achieve those goals they will need to reinvent most of what Logtalk provides. Meanwhile, decades pass.
A Man With A Clever Disguise
@ACleverDisguise
I honestly don't grok why Logtalk is so ignored in the Prolog community.
Once the penny dropped for me what was actually going on, I pretty much ditched pure Prolog from my toolkit.
Michał Majchrzak
@m_a_j_ch_rz_a_k_twitter
I would love to see real web example with Logtalk. With DB, web server etc.
3 replies
Paul Brown
@PaulBrownMagic

Once the penny dropped for me what was actually going on, I pretty much ditched pure Prolog from my toolkit.

Sounds familiar!

Paul Brown
@PaulBrownMagic

I would love to see real web example with Logtalk. With DB, web server etc.

http://owlsai.com Logtalk server-side, ClojureScript client-side. Currently setup for a user-study that's ended (so feel free to poke around, I've got the data off the server that I needed), code to get in is "SAFE" . About 10,000 lines of Logtalk, data is persisted in files (Prolog and OWL), novel-state is reconstructed from logs, AI-tutor looks to offer support. The how-to-use video explaining what it's for and how to use it is here: https://youtu.be/QFOKT9oW_dk More details about server-side including architecture diagrammed and described here: https://eprints.whiterose.ac.uk/182867/1/refactoring-the-whitby-intelligent-tutoring-system-for-clean-architecture.pdf

1 reply
Jonathon-Doran
@Jonathon-Doran

Thanks for the feedback. I've been busy on other things for the past couple of days, but have time now to look into this more. I lack understanding of some key concepts, which needs to be corrected. Otherwise I end up like the folks I used to know who wrote C++ code like FORTRAN.

@PaulBrownMagic Thanks for sharing information on your project. I would be more interested in seeing the code than seeing the working product

1 reply
didier31
@didier31

Hi Paulo, Hi Everybody,

I have a concern with logtalk threading.
I make use of threaded_call/2 because when a thread's returned result is KO, I should cancel all others threads.

I've remarked threaded_call/2 must be coupled with threaded_exit/2. A question of exit queues, I guess.
My concern is that my need is to wait termination of any thread. But, threaded_exit/2 disallows to pass free variable as tag.

As a result, either, I use threaded_call/1 but I can't call threaded_cancel/1 because it disallows free var. Either, I use threaded_call/2 but I can't wait exiting of any thread.

Is there a solution to this dilemma ?

Thank you by advance for your light.
Cheers
didier.

Paulo Moura
@pmoura
Can't you use instead the threaded/1 predicate?
didier31
@didier31
Maybe if I can play with threaded_wait and threaded_notify.
didier31
@didier31
Can threaded/1 take an arbitrary number of threads ?
Paulo Moura
@pmoura
The predicate takes a conjunction or a disjunction of goals with one thread per goal.
But are the threaded/1 predicate semantics a good fit for the problem you're solving?
didier31
@didier31
If prolog gives the opportunity to transform a list of goals in a conjunction, it's fine.
Paulo Moura
@pmoura
Easy to write a predicate to do that conversion. E.g. from the Logtalk core:
% converts a list of goals into a conjunction of goals

'$lgt_list_to_conjunction'([], true).

'$lgt_list_to_conjunction'([Goal| Goals], Conjunction) :-
    '$lgt_list_to_conjunction'(Goals, Goal, Conjunction).


'$lgt_list_to_conjunction'([], Conjunction, Conjunction).

'$lgt_list_to_conjunction'([Next| Goals], Goal, (Goal,Conjunction)) :-
    '$lgt_list_to_conjunction'(Goals, Next, Conjunction).
didier31
@didier31
I can't believe it ! :D
Nice !
More, $lgt_list_to_conjunction'/2callable.
Paulo Moura
@pmoura
This is an internal predicate. Better for you to use your own version.
didier31
@didier31
thank you very much, Paulo. I couldn't believe it would be so direct.
All right !
didier31
@didier31
Good evening, Paulo
Paulo Moura
@pmoura
Have a great weekend.
didier31
@didier31
Than you, you as well !
A Man With A Clever Disguise
@ACleverDisguise
I truly love watching as people find out how easy Prolog (and thus by extension Logtalk) makes it to manipulate code.
didier31
@didier31
And you know what ?
I spent my life, since 1989, date from when I've decided to learn Prolog, ignoring this, despite I knew everything is term in Prolog because this is not something, learnt in books or courses. One must involved in a Prolog interpreter's development to be aware of that.
didier31
@didier31

Hello Paulo,

I apologize for disturbing you again.
I have a question about threaded notifications.
I'm not sure if the notifications are received in the same order as they are sent.
Can you confirm they are, please ?

Thank you again.
Good evening, Paulo.
didier.

Paulo Moura
@pmoura
Internally, threaded notifications use message queues...
... but if you have multiple threads sending notifications, then you should not expect any order.
didier31
@didier31

Provided that these notifications are sent in sequence in the same thread to be received by only one thread.
Ok. This means I have a race condition bug.

Thank you again, Paulo.

didier31
@didier31

Hello Paulo,

In this snippet of code, I can't understand with the second clause of procMsg/0 is never called if its first clause succeeds.
procMsg/0 call is asynchronous.

:- object(sequential).

:- threaded.

:- public(begin/0).
:- mode(begin, one_or_more).

   begin :- threaded_call(procMsg).

:- public(send/1).
:- mode(send(+msg), one_or_more).

   send(Msg) :- /*(
                         threaded_peek(procMsg), 
                         threaded_exit(procMsg)   % In the hypothesis that alternative solutions of procMsg are infered on threaded_exit/1 cail
                        ;
                         true
                        ), */
                        self(Self),
                        threaded_notify(Self::msg(Msg)).

:- public(end/0).
:- mode(end, one_or_more).

   end :- self(Self),
          threaded_notify(Self::msg(term)),
          threaded_wait(Self::termack).

   procMsg :-
       self(Self),
       threaded_wait(Self::msg(Msg)),
       (
        Msg == term ->
               threaded_notify(Self::termack),
               !
              ;
               Msg
      ),
      writeln('End of the turn.').

    procMsg :-
        writeln('One more ride.'),
        procMsg.

:- end_object.

The object sequential simply process calls via notifications.
As you can see, the second sequential::send/1 call is not processed because the second clause of procMsg/0 is not called in order to rearm processing of the next notification.
Knowing that, sequential::end/0 call logically suspends the caller on thread_wait(sequential::termack).

?- sequential::begin.
true.

?- sequential::send(writeln(toto)).
true.

toto
End of the turn.
?- sequential::send(writeln(toto)).
true.

?- sequential::end.

I'm very curious to know what I'm doing wrong. Must I force the first clauss of procMsg to fail in order to trigger its second clause ?
It would be a non-conforming behaviour, then.
Can you help me, please ?

Good lunch, Paulo.

Paulo Moura
@pmoura
Why would the second clause for the procMsg/0 predicate be ever called?
You're using threaded_call/1 but there's no call to threaded_exit/1 to go over all solutions for the procMsg/0 predicate.
Anyway, you seem to be looking for the functionality provided by threaded engines.
Jonathon-Doran
@Jonathon-Doran
Maybe it is getting too late, but I'm not understanding ":- uses(meta, [map/2::maplist/2])."
I expected ":- uses(meta, [maplist/2])"
(I'm trying to pass a list of clauses into an object, and have it apply them. I figured I would map call/2 onto the list.
Jonathon-Doran
@Jonathon-Doran
I should add that I have my mapping working when I use logtalk_load to load meta, I just don't follow what is going on above.
Paulo Moura
@pmoura
See https://logtalk.org/library/library_index.html#meta The protocol declares map/2, not maplist/2. Thus, :- uses(meta, [map/2::maplist/2]). is declaraing that you are calling meta::map/2 using the maplist/2 alias. You can also write it as :- uses(meta, [map/2 as maplist/2]).. But the meta object already declares thias alias itself. As such, you can simply use :- uses(meta, [maplist/2]).
Paulo Moura
@pmoura
For those of you that use Logtalk on Windows, there are now PowerShell versions of most of the scripts, including the integrations scripts and tool scripts, including logtalk_tester and logtalk_allure_report. See https://github.com/LogtalkDotOrg/logtalk3/discussions/142
A Man With A Clever Disguise
@ACleverDisguise
Ooh! Nice! That gonig into the next release?
Paulo Moura
@pmoura
Yes.
A Man With A Clever Disguise
@ACleverDisguise
You really are a machine. :D
Paulo Moura
@pmoura