Clearing Blackboard (bb_delete)

9 views
Skip to first unread message

Michael Leuschel

unread,
Sep 2, 2021, 3:00:25 AMSep 2
to sicstu...@googlegroups.com
Hi,

I am using the SICStus blackboard primitives instead of assert/retract; it is generally considerably faster.

I wonder whether there is a way to reset / clear the blackboard in a given module, without having to store all keys somewhere else.
The predicate bb_delete/2 and bb_get/2 generate an instantiation error when the key is not given.

Kind regards,
Michael

| ?- bb_put(a,1).
yes
| ?- bb_get(a,X).
X = 1 ?
yes
| ?- bb_delete(A,B).
! Instantiation error in argument 1 of bb_delete/2
! goal: bb_delete(_401,_403)
| ?- bb_delete(a,B).
B = 1 ?
yes
| ?- bb_put(a,1).
yes
| ?- bb_get(A,B).
! Instantiation error in argument 1 of bb_get/2
! goal: bb_get(_401,_403)


matsc560515

unread,
Sep 2, 2021, 12:17:46 PMSep 2
to SICStus Users
Hi Michael. First of all, it's a bit surprising for bb_put/2 to be considerable faster than assert, since they share the core routine that stores the value. I can understand it if the value is atomic, then assert's indexing overhead gets noticeable, I imagine.
Re. resetting or clearing the blackboard without knowing the keys: currently, the only way to do it is to "reload" the module. That is, assuming that the module was defined in some file containing its :-module declaration, reload that file or some .po file that was derived from it.
It could be worth it to have one or more modules for no other purposes than their blackboards.
Good luck,
Reply all
Reply to author
Forward
0 new messages