C API examples need to be updated

Coordinator
Jan 9, 2013 at 5:00 PM
Edited Jan 9, 2013 at 5:27 PM

The C API examples examples/c/test_capi.c use several deprecated APIs, and still use the old memory management policy. We now have the new C++ API and examples for Z3. I think the C++ API is much more convenient to use and makes everything much simpler. So, I imagined nobody would use the C API anymore, and we didn't have to update examples/c/test_capi.c anytime soon. It seems I was completely wrong, several users still use test_capi.c as a "guide" for using Z3. Moreover, we keep getting questions at Stackoverflow that contain code snippets based on deprecated APIs. It is also very counter intuitive to mix the deprecated APIs with the new ones, and users frequently produce code that crashes due to memory management problems.

So, it seems the natural solution is to update examples/c/test_capi.c, or at least delete it from the next release. BTW, if we decide to keep it, we should renamed it to something like examples/c/example.c

Coordinator
Jan 9, 2013 at 5:44 PM

Sounds like a good suggestion to me. It should be relatively straightforward to translate the C# example to get a new one based on the new API. If we want to go this way, I would suggest back-porting the C# example to C++ as well, so we get a consistent set of examples. I'm happy to work on this in the (near) future, as I'll have to do something similar for ML and Java anyways.