Skip to content

Cardinality and type constraints? #180

Answered by pmoura
EllenOrange asked this question in Q&A
Discussion options

You must be logged in to vote

One solution is to define predicates that abstract asserting and retracting clauses for those predicates and verify cardinality and type constraints. It may be possible to use mode/2 directives for the dynamic/state predicates that declare the necessary cardinality and type constraints. The reflection API allows access to the contents of the mode/2 directives at runtime.

Another solution is to use the event-driven programming features:

https://logtalk.org/manuals/userman/events.html

This allows you to intercept messages, including assert and retract messages, by defining monitors for those events that will verify pre- and post-conditions. See e.g. the blocks example. There's a small perfo…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@EllenOrange
Comment options

Answer selected by EllenOrange
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants