This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/Logtalk/examples/benchmarks/database.lgt
pmoura 6b4bde14e1 Logtalk 2.30.1 files.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1903 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
2007-06-12 10:39:47 +00:00

48 lines
1.2 KiB
Plaintext

:- object(database).
:- info([
version is 2.0,
author is 'Paulo Moura',
date is 2007/04/17,
comment is 'Dynamic database benchmark utility predicates.']).
:- public(this_dyndb/1).
:- mode(this_dyndb(+nonvar), one).
:- info(this_dyndb/1, [
comment is 'Asserts and retracts a predicate in "this".',
argnames is ['Term']]).
:- public(self_dyndb/1).
:- mode(self_dyndb(+nonvar), one).
:- info(self_dyndb/1, [
comment is 'Asserts and retracts a predicate using ::/1.',
argnames is ['Term']]).
:- public(obj_dyndb/1).
:- mode(obj_dyndb(+nonvar), one).
:- info(obj_dyndb/1, [
comment is 'Asserts and retracts a predicate using ::/2.',
argnames is ['Term']]).
:- private([pred_this/1, pred_self/1, pred_obj/1]).
:- dynamic([pred_this/1, pred_self/1, pred_obj/1]).
% direct calls to assertz/1 and retract/1:
this_dyndb(N) :-
assertz(pred_this(N)),
retract(pred_this(N)).
% calls to assertz/1 and retract/1 using ::/1:
self_dyndb(N) :-
::assertz(pred_self(N)),
::retract(pred_self(N)).
% calls to assertz/1 and retract/1 using ::/2:
obj_dyndb(N) :-
this(This),
This::assertz(pred_obj(N)),
This::retract(pred_obj(N)).
:- end_object.