G3Kappa / Ergo

Other
4 stars 0 forks source link

Databases #61

Open G3Kappa opened 1 year ago

G3Kappa commented 1 year ago

Despite the simplicity with which Ergo can interface to C#, it would be nice to provide a default database-like API to handle persistent state idiomatically. This has become especially evident during the integration of Ergo with Fiero, the game I'm working on, where something as simple as incrementing an integer needs to be done rather inefficiently via dynamic predicates.

G3Kappa commented 1 year ago

A full-blown SQL database seems redundant since Prolog is already a declarative language where the user runs queries.

A simple table-like term storage system that (optionally) persists on disk would be useful though. If the user needs a to use a battle-proven dbms they can write an adapter already, but it would be pointless to choose one at random just for Ergo.

As always, SWI provides some useful insight: the recorded database seems like a decent solution, and it's widely supported.

Transactions should also be implemented, and this introduces the need for mutexes. While Ergo has no threading facilities yet (see #7), several Ergo scripts can run at the same time in the same local context if the C# host wills it, leading to potential data races.