Giter Club home page Giter Club logo

delay's People

Contributors

mndrix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

fnogatz

delay's Issues

implement more predicates

I searched for uses of when/2 in Prolog code on my machine. These predicates would benefit from delay/1 support:

  • error:must_be/2
  • =:=/2
  • callable/2

I can probably generalize from those few examples to include other operators (like =:=) and other type checks (like callable).

delay/1 with !/0

Jan pointed out

delaying over a cut changes the semantics.
So, if you use this you either should not use cuts or be very
careful with them.

The first improvement is to document this circumstance so that developers are aware of the problem.

It'd also be nice to generate warnings about delay/1 that occur before !/0 in a clause. This doesn't cover all problem scenarios but it should help notice some common ones. If I go this route, there needs to be a way to say, "I know what I'm doing, leave me alone". Ideally, there should be a style_check/1 mode that enables this warning.

support maplist/3

The library should provide support for maplist/3, maplist/4, etc. It should also work even if the maplist calls have been expanded via apply_macros.pl.

We can probably just look for a predicate whose name starts with __aux_maplist to detect that it's a maplist expansion.

change internal implementation

I want users to be able to add delay/1 support to any predicates they care about. Making that happen requires a decent rewrite. As follows:

  • strip all macros from this code. it must work with mode/1 as it's written
  • replace g and n with ground and nonvar, respectively
  • make sure that each delay/1 clause cuts before calling when/2. otherwise, when/2 can fail because all arguments are ground and the underlying goal fails. that would backtrack to the final delay/1 clause and throw an exception. Be sure to write a failing test for this first, then make changes to make it pass. without a test, I'm sure I'll encounter this same corner case again.
  • have delay/1 consult mode/1 to build a when/2 goal then assert it as an additional clause on delay/1 (the assertion is an optimization)
  • change delay/1 into meta_predicate delay(0) and change mode/1 so that each built-in predicate is prefaced with system:. Look at mode/1 with the module-qualified head. If there's no mode for that, call predicate_property(Head, imported_from(Module)) to determine if this predicate is originally from another module. Perform the mode/1 look up using that module. If there's no mode/1 declaration in either case, throw an error with instructions about how to add support for other predicates.
  • make sure delay_followup/1 always has a nonvar(List) guard in the list(_) case
  • :- multifile mode/1.
  • at this point, one can just add delay:mode(foo:bar(ground,_)) facts to support additional predicates.
  • clean up and document before releasing a new version and posting to the mailing list

See also block/1

SWI-Prolog's SICSTUS compatibility layer includes the block/1 directive which fills a niche similar to delay/1. Link to it from the documentation and perhaps comment on the differences between each approach. For example, does block/1 work with built-in predicates? Does it work with foreign predicates? Does it work with dynamic predicates? I'm pretty sure that delay/1 works with all of them. I think that delay/1 has a more flexible mode language than block/1

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.