Re: warning: possibly unused local top-level variable `%foo?-procedure'

Tomas Volf <[email protected]>
Newsgroups gmane.lisp.guile.user
Message-ID <ZmI9mUNgiV9pnBeS@ws>
On 2024-06-06 22:02:50 +0200, Linus Björnstam wrote:
> Which version are you using? All my similar issues with srfi-9 went away last year when srfi things were marked maybe-unused.

I am using the latest 3.0.9.  However thanks to your hint about maybe-unused, I
can see this:

    $ git log v3.0.9.. -- module/srfi/srfi-9.scm
    commit 7fef214f6e0df4004020fec530e808c476f2d2bf
    Author: Andy Wingo <[email protected]>
    Date:   Sun Mar 17 09:52:49 2024 +0100

        Remove vestigial code from srfi-9

        * module/srfi/srfi-9.scm (%define-record-type): No need to define
        record-layout.

    commit 19c7969fff223f28cad90e21ae04a0a5852901fc
    Author: Andy Wingo <[email protected]>
    Date:   Thu Aug 24 11:41:15 2023 +0200

        define-inlinable marks residualized procedure as maybe-unused

        * module/ice-9/boot-9.scm (define-inlinable):
        * module/srfi/srfi-9.scm (define-tagged-inlinable): Add maybe-unused
        declaration.  Also require at least one body expr, otherwise the
        metadata declaration could escape as the proc body.

So it looks like this is not in any released version yet.  And indeed, when I
try to compile it using the current master, the warning goes away.

I wonder how to work around it in the mean time.  I guess I could just put
%foo?-procedure as a top-level expression.  This seems to not produce any
warnings:

    (define-module (x)
      #:use-module (srfi srfi-9)
      #:export (<foo>
                foo?
                make-foo))

    (define-record-type <foo> (make-foo) foo?)
    %foo?-procedure

I guess there should be pretty much zero performance impact, correct?  Are there
any side effects I might not be aware of?

>
> I don't have a computer this week so I cannot try your code. Sorry.

No worries, you were helpful already, enjoy your no-computer time :)

>
> --
>   Linus Björnstam
>
> On Wed, 5 Jun 2024, at 17:02, Tomas Volf wrote:
> > Hello,
> >
> > I am getting following warning from a guild compile:
> >
> >     warning: possibly unused local top-level variable `%foo?-procedure'
> >
> > And I am not sure how to tackle it.  This is my full source code:
> >
> >     (define-module (x)
> >       #:use-module (srfi srfi-9)
> >       #:export (<foo>
> >                 foo?
> >                 make-foo))
> >
> >     (define-record-type <foo> (make-foo) foo?)
> >
> > When I try to compile it:
> >
> >     $ guild compile -W 3 -o x.go x.scm
> >     x.scm:7:0: warning: possibly unused local top-level variable
> > `%foo?-procedure'
> >     wrote `x.go'
> >
> > I would (for obvious reasons) like to keep my compilation warning-free.  I can
> > think of two approaches:
> >
> > 1. Export the %foo?-procedure
> >      I think this would confuse downstream users, since they are not expected to
> >      use it directly.
> >
> > 2. Mark the procedure as used
> >       In C I could use `(void)proc;', is there an equivalent of that construct
> >       in Guile?
> >
> > Are there other options?  How are you approaching it?
> >
> > Thank you and have a nice day,
> > Tomas Volf
> >
> > PS: I am not even sure why this warning happens, the `foo?' syntax transformer
> > is exported and *does* reference it (as far as I can tell from ,expand).
> >
> > --
> > There are only two hard things in Computer Science:
> > cache invalidation, naming things and off-by-one errors.
> >
> > Attachments:
> > * signature.asc

Have a nice day,
Tomas Volf

--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEt4NJs4wUfTYpiGikL7/ufbZ/wakFAmZiPZkACgkQL7/ufbZ/
wakjdBAAkZ0quGWrA1UumN2qPH6EKLlrRTIIabgyC+saUzffy4UwkXu27hpuSwE9
jwJTUVRXYAy0lZzyzCVW6L9yxyYwByQD/b/O2X/pq1fsRo2V8U3qzODT8h2KiTKq
GN8ZjCY0BQ45qLkF5AIWo1AT5U7M0QZfk/YyH5T8ZDundAIzqB4ZbZ/m8qb2BYFe
1D1IV+JKwO7DWSPc3TG6jxkI1IL3Y77+h32OXEgFGbF6SwVG1YnEUZ4LoXg+o9Gs
7UF87k1GBgjMPzVOsvsWOJRinjYft+xWOduHbVCwHfnA0mFODVT1r54R0i2BHCSd
ZP8xsj69NlRBG+mUTkmc2GXRu70bXrDcg7AHw96vK0UuJweL3PMO5NUq/HK1SZ3i
1SkZMo1NN/TcxNnI3HwnXozUDwXLDCIcMXO8r+xxe6kw27NzonspjyC+qCCuiNxe
HrL6+hbmWr4ybP8Gqg6DKFWYFklGctG2cnakrRn/oBADWwABv1knnGqIh3GxJJcs
Cbuu1QE2ig7+PL1J5sjt8EVYWNW5KsYIU4kLjmO77e3nylAwat/mJh4aNze2UNeo
jtGHsl7pHPZh2YB2ZqqAN9aECRHUVo/MlBplGoC8YjNWuIeZDCClV8g7e6pp2Agl
jRvFUIZdNRfGF//uGo4XqNho2xjjjjqJrumjqsvKwjXBgegicm4=
=svBx
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.