Code Monkey home page Code Monkey logo

Comments (4)

didoudiaz avatar didoudiaz commented on July 22, 2024

ensure_loaded/1 is not yet implemented (it has some issues for a native compiler). gprolog proposes the ensure_linked/1 directive which could help you.

from gprolog.

 avatar commented on July 22, 2024

Currently the work around is to use include/1. But include/1
is not smart, it cannot deal with an import graph. The main
benefit of ensure_loaded/1 would be to avoid duplicate

include/1, which is not part of the requirement of include/1.
So one workaround would be if one could define user
directives, like:

:- dynamic(visited/1).

ensure_loaded(Path) :- 
     visited(Path), !.
ensure_loaded(Path) ;-
     assertz(visited(Path)),
     include(Path).

from gprolog.

pmoura avatar pmoura commented on July 22, 2024

ensure_loaded/1 is not yet implemented (it has some issues for a native compiler). gprolog proposes the ensure_linked/1 directive which could help you.

As a side note, Logtalk provides the functionality of the ensure_loaded/1 directive. See:
https://logtalk.org/manuals/userman/programming.html?highlight=reload#flag-reload

from gprolog.

 avatar commented on July 22, 2024

Logtalk is not ISO core standard compliant in the way it deals
with Prolog texts. The minimum Logtalk would need to provide would
be include/1 and ensure_loaded/1. But it begs the question whether

any useful semantic can be made, Logtalk compilation units have
a name braket. On the other hand the ISO core standard indeed specifies
ensure_loaded/1 based on include/1. It mentions include explicitly:

Unbenannt

But there is a small gap, the standard doesn't elaborate when
Prolog text designators denote the same Prolog text. So I have
a new proposal, assuming a predicate absolute_file_name/2 that

then is responsible for the sameness:

ensure_loaded(Path) :- 
    absolute_file_name(Path, AbsPath),
    \+ visited(AbsPath), !,
    assertz(visited(AbsPath)),
    include(Path).
ensure_loaded(_).

But a challenge can be to have visited/1 automatically flushed
sometimes, so as to regain re-consult semantics.

from gprolog.

Related Issues (20)

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.