Re: get unused integer



Hello Christian,

thank you for your code. I think it is not exactly what I wanted, but
it did give me some inspiration.

As my program will use multiple threads anyway (although only at a
later stage of development), it probably makes sense to adjust the
label-assigning technique to this fact.

I think I can assign an identity to each parsing procedure (s(T1, T3,
Procedure) ...) and use the following simple code:

:- dynamic(assigned/2).

get_new_label(Label, Procedure) :-
label(Label),
not(assigned(Label, Procedure)),
assert(assigned(Label, Procedure)).

label(0).

label(X) :-
label(Y),
X is Y + 1.


I am not sure, though, that this code does not contain any traps. I
never used multiple threads in (Swi) Prolog before.

So, maybe someone with greater experience would like to comment on
this code? Is it safe? Is it efficient?

Simon
.