Next: , Previous: , Up: prolog   [Index]


16.12 Dynamic features

A dynamic feature is a feature that can be added to the update flow of a dynamic variable, you may want it’s state to be saved and restored when a continuation is stored and later executed. You may want the state to be started and restored in a more fine grained pattern when you do paralell. You may want the state to be restored when controls leaves a function either by sucessing or by back tracking and so on. Guile log sports the feature to allow all stateful data such as dynamic functions dynamic vlists, vhashes, operator tables, character translations, flags, and any functional datastructure you can think of that you define in guile scheme and exposed to prolog.

16.12.1 API.

There is a section about the scheme part of this interface, here we concentrate on the prolog part. The dynamin objects constructures will be defined in their associated library section, here we just describes what we can impose on them

16.12.1.1 handles

Use the below accessors to get a handle of various prolog aspects like operator table char conversion table and prolog flags table for defining dynamic features on them.

get_prolog_operators_handle(Handle)

get_prolog_flags_handle(Handle)

get_prolog_conversion_handle(Handle)

16.12.1.2 backtracking versions

backtrack_dynamic_object(o, ...) Make sure that after this position and forward in the execution o,... will follow any backtracking and also backtrack to the value that they had at the junction unless a new dynamic feature is encountered.

not_backtrack_dynamic_object(o, ...) Make sure that after this position and forward in the execution o,... will not follow a backtracking unless a new dynamic feature is encountered.

with_backtrack_dynamic_object(o, ...,code) Make sure that inside code the execution o,... will follow any backtracking unless a new dynamic feature is encountered

with_not_backtrack_dynamic_object(o, ...,code) Make sure that inside code the execution o,... will not follow any backtracking unless a new dynamic feature is encountered

16.12.1.3 guarding states

state_guard_dynamic_object(o, ...), A left limit for which state is restored if the state reinstated over the guard, unless other guards are encountered after this guard.

state_guard_dynamic_object_zip(o, ...), A left limit for which state is restored if the state reinstated over the guard, unless other guards are encountered after this guard. The difference to the above is that this can be placed before a control construct that do parallell execution like interleaving disjunciton or zipping of goals. Hence we do not need to place it in each branch essentially meaning that when each branch is reinstated the dynamic objects value is reinstated for that branch else the control would not pass over the guard and no reinstation would result.

always_state_guard_dynamic_object(o, ...), A left limit for which state is restored always independentof if the state reinstates over the guard, unless other guards are encountered after this guard.

with_state_guard_dynamic_object(o,...,code), will guard the state only in code. But reinstation will not happen unless reinstation is from a backtracked state. That is if reinstation i essentially back tracking it will not restire the state.

with_state_guard_dynamic_object_zip(o,...,code), will guard the state only in code. The same as above but the state will be reinstated when zip et all switches branches.

with_always_state_guard_dynamic_object(o,....,code), ditto but inside code always reinstate state.

16.12.1.4 guarding values

fluid_guard_dynamic_object(o,...), this will make sure that o,... is resetted to the value they had when the program passed over the guard, and reset to the value it had when control backttraced over it at reinstation over the guard.

with_fluid_guard_dynamic_object(o,...,code), the same as above, but with an extra fluid guard at the success edge of code.

with_fluid_guard_dynamic_object_once(o,...,code), the same as above but takes an optimization by forcing the code to only succeeds once.

16.12.1.5 utils,

There are a few general util funcitons used to manage the state of the dynamic objects in a safe way.

set_dynamic_object(m1 -> m2), the state m1 state is transferd to m2

copy_dynamic_object(m1 -> M2), M2 will bind to a newly created object containing the state of m1.

Added ontop of this is how to evolve the state data like asserting new facts or to add a new pair on a map. But these operations is defined in each of the library sections.


Next: , Previous: , Up: prolog   [Index]