unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* warning: possibly unused local top-level variable `%foo?-procedure'
@ 2024-06-05 15:02 Tomas Volf
  2024-06-06 20:02 ` Linus Björnstam
  0 siblings, 1 reply; 4+ messages in thread
From: Tomas Volf @ 2024-06-05 15:02 UTC (permalink / raw)
  To: guile-user

[-- Attachment #1: Type: text/plain, Size: 1272 bytes --]

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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: warning: possibly unused local top-level variable `%foo?-procedure'
  2024-06-05 15:02 warning: possibly unused local top-level variable `%foo?-procedure' Tomas Volf
@ 2024-06-06 20:02 ` Linus Björnstam
  2024-06-06 22:52   ` Tomas Volf
  0 siblings, 1 reply; 4+ messages in thread
From: Linus Björnstam @ 2024-06-06 20:02 UTC (permalink / raw)
  To: Tomas Volf, guile-user

Which version are you using? All my similar issues with srfi-9 went away last year when srfi things were marked maybe-unused.

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

-- 
  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



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: warning: possibly unused local top-level variable `%foo?-procedure'
  2024-06-06 20:02 ` Linus Björnstam
@ 2024-06-06 22:52   ` Tomas Volf
  2024-06-07  7:26     ` Linus Björnstam
  0 siblings, 1 reply; 4+ messages in thread
From: Tomas Volf @ 2024-06-06 22:52 UTC (permalink / raw)
  To: Linus Björnstam; +Cc: guile-user

[-- Attachment #1: Type: text/plain, Size: 3656 bytes --]

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 <wingo@pobox.com>
    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 <wingo@pobox.com>
    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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: warning: possibly unused local top-level variable `%foo?-procedure'
  2024-06-06 22:52   ` Tomas Volf
@ 2024-06-07  7:26     ` Linus Björnstam
  0 siblings, 0 replies; 4+ messages in thread
From: Linus Björnstam @ 2024-06-07  7:26 UTC (permalink / raw)
  To: Tomas Volf; +Cc: guile-user

Thank you for making me realize I use guile-master...

I am not really sure what that binding expands into, but it is reasonable to think it has no effect on performance 

-- 
  Linus Björnstam

On Fri, 7 Jun 2024, at 00:52, Tomas Volf wrote:
> 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 <wingo@pobox.com>
>     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 <wingo@pobox.com>
>     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.
>
> Attachments:
> * signature.asc



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-06-07  7:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-05 15:02 warning: possibly unused local top-level variable `%foo?-procedure' Tomas Volf
2024-06-06 20:02 ` Linus Björnstam
2024-06-06 22:52   ` Tomas Volf
2024-06-07  7:26     ` Linus Björnstam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).