guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

foreign objects and the garbage collector


From: Tim Meehan
Subject: foreign objects and the garbage collector
Date: Sat, 4 Sep 2021 07:41:49 -0500

I was looking at writing something to interact with gpsd.
There is a shared memory interface, and a Unix socket interface. The
protocol spoken by gpsd is JSON, so I figured that I would just open up a
socket and start talking ... however ... really early on in the man page,
it says "it is a bad idea for clients to speak the protocol directly" (
https://gpsd.gitlab.io/gpsd/gpsd_json.html) presumably since the protocol
was likely to change? They didn't elaborate ...

There is a C interface described at (https://gpsd.gitlab.io/gpsd/libgps.html),
which has the familiar "open-and-get-opaque-thing" and
"close-opaque-thing-when-done" design.

I'd rather not compile anything in C, and just use the tools in Guile to
interact with libgps. Is there a way to get Guile's garbage collector to
call "gps_close" on the opaque structure returned by "gps_open"? Or is this
something that would be more handily implemented in a C extension?

Right now, because I'm just not concerned about sloppiness, I've just been
speaking the wire protocol, but I do feel bad about being sloppy and wanted
to clean it up for others to use perhaps.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]