From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tim Meehan Newsgroups: gmane.lisp.guile.user Subject: foreign objects and the garbage collector Date: Sat, 4 Sep 2021 07:41:49 -0500 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33212"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-user Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sat Sep 04 14:42:37 2021 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mMV0G-0008S3-Oc for guile-user@m.gmane-mx.org; Sat, 04 Sep 2021 14:42:36 +0200 Original-Received: from localhost ([::1]:42848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMV0F-0006en-Ms for guile-user@m.gmane-mx.org; Sat, 04 Sep 2021 08:42:35 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45220) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMUzp-0006c9-SE for guile-user@gnu.org; Sat, 04 Sep 2021 08:42:10 -0400 Original-Received: from mail-qt1-x829.google.com ([2607:f8b0:4864:20::829]:39440) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mMUzi-00077L-LE for guile-user@gnu.org; Sat, 04 Sep 2021 08:42:08 -0400 Original-Received: by mail-qt1-x829.google.com with SMTP id t35so1563236qtc.6 for ; Sat, 04 Sep 2021 05:42:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=2PlkkCyNyI9sB4/qhziWR+YJdSo+/Lj0Xsv/m/k0nwg=; b=CnXxykDr31GhDPf+664+L0N4Knw1OtYNiMfQP/RDJHzgFBmG7sD0fB+rjVj4GyGn9R CvKmyvew6WYIJQYwmoLza4Kd4oncQ2Wm6q3Yc2whgvvFqDmqm89fKEC4N07qloUBHsuB RJtHU9qp+UBSSeFRavS7ec9Lr76zrvu/iQADTjutypzG9OrqgdNZ2ffULwJFBHhx1sut kmq9arDtNAFPFOtMhxQxqIVNoKs5gY1lM22+SVsgKHaAugW9uIEkbmEfRiON0ucANbf6 mMzC0KBI2Gf1r5hgqPbp0drva3xH3DVutusmdJQDktEdGSKszZBvxgV4O/RCNSkCcZom MNsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=2PlkkCyNyI9sB4/qhziWR+YJdSo+/Lj0Xsv/m/k0nwg=; b=c1IHWau4ereVFBv0+Kc013Pc2z26Kk6y8Z84Kwhdyef4Viia6yUtJAiMoZ0Upsq6c8 hqo8Tdr3FpxqqUTeljh9HfVxM/r3jYkRqtDC9tKPp5AT7Kzjhm7KJFZU5fcSXWqTmT1Y yQJHP02ySc9GuP5vibjF0pj5wRF4/wq54krnBmLUBT8KwnQzrPOys2qyobnZKFpyJ/NK Bkz5vamQ89Plwd1BAyyP3IRm6MsIKQ4gtdOU6I4dc9BgiCWkqwTeAcQPycF0yR+JEYg0 rLodD/BCdWOHu1yZPJp+jV2f3tGJv/mlpyEqHHMr4g2bE/sIifq7Dxz9aXOg/7yqmWuX rvew== X-Gm-Message-State: AOAM533SzoFtjIVlk6eCeNlOHZ/WPLWcpTBsBy5AU9U0S8gupzEO+4r8 0kRUhOF4X/7M6FUoMBeDVpQ5IMuee/Wg09sBI5UV1Jb5eZM= X-Google-Smtp-Source: ABdhPJxrQ+Srbmb79ypmejoquiKFLFjw0LyuVBnD30V9tEVMfzIovvE4GlyKc0mm5fxEsRbUN5YqqKlqtpIkRHH4FR0= X-Received: by 2002:a05:622a:28d:: with SMTP id z13mr3165219qtw.313.1630759320654; Sat, 04 Sep 2021 05:42:00 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::829; envelope-from=btmeehan@gmail.com; helo=mail-qt1-x829.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:17708 Archived-At: 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.