Git Product home page Git Product logo

Comments (9)

jariazavalverde avatar jariazavalverde commented on July 28, 2024 1

The Tau Prolog sandbox is just that, a sandbox, and it allows you to set an inference limit to prevent the browser from freezing. It is built using the 3 main methods of Tau Prolog: consult, query and answer.

http://tau-prolog.org/manual/a-simple-tutorial

You can set up a sandbox that runs a query with a limit of, say, 1000 inferences. If the limit of inferences is reached, in the callback of the answer method, you can make it continue looking for the answer. That way the interpreter can stop working automatically from time to time, so that the browser takes care of the rest of the events.

In our current sandbox, when the query stops the user has to explicitly request that the search continue, requesting another answer. But this behavior can be changed by modifying the callback.

imagen

Regarding sleep/1 predicate, every time you stop the execution so that the browser processes the rest of the events, whatever way it is, there may be a delay. Precisely because you stop for other events to be processed. JavaScript is single-thread, and this is just a negative effect of its concurrency model. In any case, both with sleep/1 predicate or with the inference limit, the user can choose how often to stop the execution.

from sandbox.

jariazavalverde avatar jariazavalverde commented on July 28, 2024 1

Added. You only have to uncheck the stop option (the limit of inferences is still necessary).

imagen

You can check the option while running to stop the execution in the next limit of inferences.

from sandbox.

jariazavalverde avatar jariazavalverde commented on July 28, 2024

Tau Prolog is non-blocking, but as a National Department of Traffic slogan said: we can't drive for you. To release the browser you have two options: call an asynchronous predicate (such as sleep/1) that sleeps execution for a while, or use the inference limit that you can set in Tau Prolog.

For instance, the following code doesn't freeze the browser:

:- use_module(library(os)).

p :-
    sleep(0),
    write(p), nl,
    p.

Tau Prolog allows you to create a sandbox that sleeps every x inferences, but it doesn't by default because that delays execution.

from sandbox.

Jean-Luc-Picard-2021 avatar Jean-Luc-Picard-2021 commented on July 28, 2024

Ok, interesting, you can als cancel, by checking stop again.
But what is a good limit value? The default 10000 seems a
little too high, the GUI feels jiggy.

from sandbox.

jariazavalverde avatar jariazavalverde commented on July 28, 2024

It depends on the browser and the program. Something like 1000 should be fine, but it's a matter of testing I guess. (Note that you have to reconsult after setting the limit).

from sandbox.

Jean-Luc-Picard-2021 avatar Jean-Luc-Picard-2021 commented on July 28, 2024

Strange I have hit some browser incompatibility, on MacOSX.

The new feature works in Seamonkey:

Bildschirmfoto 2022-02-09 um 00 18 54

It does not work in Chrome:

Bildschirmfoto 2022-02-09 um 00 18 08

from sandbox.

jariazavalverde avatar jariazavalverde commented on July 28, 2024

It does not work in Chrome:

That is probably due to the browser cache. Refresh with Cntrl+F5 or clear the cache.

from sandbox.

Jean-Luc-Picard-2021 avatar Jean-Luc-Picard-2021 commented on July 28, 2024

Will check the browser later again.

I always admire Steve Jobs, how he introduced the MacIntosh
with a mouse that only had one button. Those times there were
mouses with 3 buttons.

So currently trying to figure out what a good GUI would be.
I cannot speak for Tau Prolog. But in my system Limit is a
system resource, that the end-user has nothing

to do with. It is planned that for non-blocking via some
auto-tuning the optimal value is found. Browsers have
a certain affinity to 60 frames per second.(*)

Not yet sure how this turns out. For the control buttons,
I am rather think of something else. Don't know yet what.
Was just having a look at SWISH, it shows me an animation

and an abort button:

Bildschirmfoto 2022-02-09 um 01 06 45

after a while it shows stats:

Bildschirmfoto 2022-02-09 um 01 08 03

the abort button shows again after redo:

Bildschirmfoto 2022-02-09 um 01 09 23

(*)
I found some docu about that. A browser might also updrade
or downgrade the frequency. There is also something related
to animation, called requestAnimationFrame(), but this is

probably not needed for DOM updates.

from sandbox.

Jean-Luc-Picard-2021 avatar Jean-Luc-Picard-2021 commented on July 28, 2024

You can check here, but a monitor might have more Hz:

https://www.testufo.com/animation-time-graph
Bildschirmfoto 2022-02-09 um 01 25 03

from sandbox.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.