GNU bug report logs - #51383
noobie way of incorrectly using (guix records)

Previous Next

Package: guix;

Reported by: Joshua Branson <jbranso <at> dismail.de>

Date: Mon, 25 Oct 2021 06:17:02 UTC

Severity: normal

Done: Joshua Branson <jbranso <at> dismail.de>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 51383 in the body.
You can then email your comments to 51383 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guix <at> gnu.org:
bug#51383; Package guix. (Mon, 25 Oct 2021 06:17:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Joshua Branson <jbranso <at> dismail.de>:
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Mon, 25 Oct 2021 06:17:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Joshua Branson <jbranso <at> dismail.de>
To: bug-guix <at> gnu.org
Subject: noobie way of incorrectly using (guix records) 
Date: Mon, 25 Oct 2021 02:15:54 -0400
So I made a pretty noobie-like mistake a few minutes ago.  When one
tries to make a (record-configuration), he invariably create an
infinite number of records.  The guile compiler eventually runs out
of memory and stops compiling.

(use-modules (guix records))

(define-record-type* <record-configuration>
  record-configuration make-record-configuration
  record-configuration?
  (command record-configuration-command
           ;; the error is here is on the next line
           (default (record-configuration))))  

(record-configuration)


This is not possible with (srfi sfri-9)


(use-modules (srfi srfi-9))

(define-record-type <employee>
  (make-employee name age (make-employeee 5 5 5))
  employee?
  (name    employee-name)
  (age     employee-age    set-employee-age!)
  (salary  employee-salary set-employee-salary!))

(make-employee)


The above results in a syntax error.


Is this a "feature" and not a bug?  I feel like this is a trivial bug,
and I am certain that other bugs are of greater importance.

Thanks,

Joshua




Information forwarded to bug-guix <at> gnu.org:
bug#51383; Package guix. (Mon, 25 Oct 2021 07:50:02 GMT) Full text and rfc822 format available.

Message #8 received at 51383 <at> debbugs.gnu.org (full text, mbox):

From: zimoun <zimon.toutoune <at> gmail.com>
To: Joshua Branson <jbranso <at> dismail.de>, 51383 <at> debbugs.gnu.org
Subject: Re: bug#51383: noobie way of incorrectly using (guix records)
Date: Mon, 25 Oct 2021 09:48:53 +0200
Hi,

On Mon, 25 Oct 2021 at 02:15, Joshua Branson via Bug reports for GNU Guix <bug-guix <at> gnu.org> wrote:

> So I made a pretty noobie-like mistake a few minutes ago.  When one
> tries to make a (record-configuration), he invariably create an
> infinite number of records.  The guile compiler eventually runs out
> of memory and stops compiling.
>
> (use-modules (guix records))
>
> (define-record-type* <record-configuration>
>   record-configuration make-record-configuration
>   record-configuration?
>   (command record-configuration-command
>            ;; the error is here is on the next line
>            (default (record-configuration))))  
>
> (record-configuration)

This <record-configuration> is defined by creating recursively another
instance.  Thus, It is expected that it does not work, no?

Reading the doc,

  1. what do you want to achieve?
  2. what does it appear to you buggy?  Or what do you think the
     “correct” behaviour should be?

--8<---------------cut here---------------start------------->8---
(define-syntax define-record-type*
  (lambda (s)
    "Define the given record type such that an additional \"syntactic
constructor\" is defined, which allows instances to be constructed with named
field initializers, à la SRFI-35, as well as default values.  An example use
may look like this:

  (define-record-type* <thing> thing make-thing
    thing?
    this-thing
    (name  thing-name (default \"chbouib\"))
    (port  thing-port
           (default (current-output-port)) (thunked))
    (loc   thing-location (innate) (default (current-source-location))))

This example defines a macro 'thing' that can be used to instantiate records
of this type:

  (thing
    (name \"foo\")
    (port (current-error-port)))

The value of 'name' or 'port' could as well be omitted, in which case the
default value specified in the 'define-record-type*' form is used:

  (thing)

The 'port' field is \"thunked\", meaning that calls like '(thing-port x)' will
actually compute the field's value in the current dynamic extent, which is
useful when referring to fluids in a field's value.  Furthermore, that thunk
can access the record it belongs to via the 'this-thing' identifier.

A field can also be marked as \"delayed\" instead of \"thunked\", in which
case its value is effectively wrapped in a (delay …) form.

A field can also have an associated \"sanitizer\", which is a procedure that
takes a user-supplied field value and returns a \"sanitized\" value for the
field:

  (define-record-type* <thing> thing make-thing
    thing?
    this-thing
    (name  thing-name
           (sanitize (lambda (value)
                       (cond ((string? value) value)
                             ((symbol? value) (symbol->string value))
                             (else (throw 'bad! value)))))))

It is possible to copy an object 'x' created with 'thing' like this:

  (thing (inherit x) (name \"bar\"))

This expression returns a new object equal to 'x' except for its 'name'
field and its 'loc' field---the latter is marked as \"innate\", so it is not
inherited."
--8<---------------cut here---------------end--------------->8---

(Argh, I do not know how to read/display the docstring from the REPL,
another annoying* story. :-))


> This is not possible with (srfi sfri-9)
>
> (use-modules (srfi srfi-9))
>
> (define-record-type <employee>
>   (make-employee name age (make-employeee 5 5 5))
>   employee?
>   (name    employee-name)
>   (age     employee-age    set-employee-age!)
>   (salary  employee-salary set-employee-salary!))

Well, ’(guix records)’ allows to do more than ’(srfi srfi-9)’.  Aside, I
am not convinced that this latter snippet is similar than the former
previous one.


Cheers,
simon


*annoying REPL, I get:

--8<---------------cut here---------------start------------->8---
scheme@(guix-user)> ,describe define-record-type*
While executing meta-command:
Syntax error:
unknown file:79:10: source expression failed to match any pattern in form define-record-type*
--8<---------------cut here---------------end--------------->8---




Information forwarded to bug-guix <at> gnu.org:
bug#51383; Package guix. (Mon, 25 Oct 2021 09:37:01 GMT) Full text and rfc822 format available.

Message #11 received at 51383 <at> debbugs.gnu.org (full text, mbox):

From: Joshua Branson <jbranso <at> dismail.de>
To: zimoun <zimon.toutoune <at> gmail.com>
Cc: 51383 <at> debbugs.gnu.org
Subject: Re: bug#51383: noobie way of incorrectly using (guix records)
Date: Mon, 25 Oct 2021 05:36:39 -0400
zimoun <zimon.toutoune <at> gmail.com> writes:

> Hi,
>
> On Mon, 25 Oct 2021 at 02:15, Joshua Branson via Bug reports for GNU Guix <bug-guix <at> gnu.org> wrote:
>
>> So I made a pretty noobie-like mistake a few minutes ago.  When one
>> tries to make a (record-configuration), he invariably create an
>> infinite number of records.  The guile compiler eventually runs out
>> of memory and stops compiling.
>>
>> (use-modules (guix records))
>>
>> (define-record-type* <record-configuration>
>>   record-configuration make-record-configuration
>>   record-configuration?
>>   (command record-configuration-command
>>            ;; the error is here is on the next line
>>            (default (record-configuration))))  
>>
>> (record-configuration)
>
> This <record-configuration> is defined by creating recursively another
> instance.  Thus, It is expected that it does not work, no?

Yes that is correct.  I am only slightly annoyed at the lack of a
helpful error message.  Thanks for helping me clarify my point.  I was
working on a rather large collection of guix records for an opensmtpd
service configuration.  The file is about 1,000 lines long.  Trying to
find that error without a helpful error message was slightly annoying.

I agree that the fault was mine and I do not believe the bug can be
fixed.  Rather it would be nice to have a more helpful error message.

It could be possible that guile offers such flexibility in general that
the compiler is unable to provide good error messages in all situations.
I am just hoping for a better error message somewhere, ether in the
compiler or something in the (define-syntax-record* macro.  Is it
possible to get a better error message?  Is that a thing worth pursuing?
Or is the fix worse than the present condition?

> Reading the doc,
>
>   1. what do you want to achieve?
>   2. what does it appear to you buggy?  Or what do you think the
>      “correct” behaviour should be?
>
> (define-syntax define-record-type*
>   (lambda (s)
>     "Define the given record type such that an additional \"syntactic
> constructor\" is defined, which allows instances to be constructed with named
> field initializers, à la SRFI-35, as well as default values.  An example use
> may look like this:
>
>   (define-record-type* <thing> thing make-thing
>     thing?
>     this-thing
>     (name  thing-name (default \"chbouib\"))
>     (port  thing-port
>            (default (current-output-port)) (thunked))
>     (loc   thing-location (innate) (default (current-source-location))))
>
> This example defines a macro 'thing' that can be used to instantiate records
> of this type:
>
>   (thing
>     (name \"foo\")
>     (port (current-error-port)))
>
> The value of 'name' or 'port' could as well be omitted, in which case the
> default value specified in the 'define-record-type*' form is used:
>
>   (thing)
>
> The 'port' field is \"thunked\", meaning that calls like '(thing-port x)' will
> actually compute the field's value in the current dynamic extent, which is
> useful when referring to fluids in a field's value.  Furthermore, that thunk
> can access the record it belongs to via the 'this-thing' identifier.
>
> A field can also be marked as \"delayed\" instead of \"thunked\", in which
> case its value is effectively wrapped in a (delay …) form.
>
> A field can also have an associated \"sanitizer\", which is a procedure that
> takes a user-supplied field value and returns a \"sanitized\" value for the
> field:
>
>   (define-record-type* <thing> thing make-thing
>     thing?
>     this-thing
>     (name  thing-name
>            (sanitize (lambda (value)
>                        (cond ((string? value) value)
>                              ((symbol? value) (symbol->string value))
>                              (else (throw 'bad! value)))))))
>
> It is possible to copy an object 'x' created with 'thing' like this:
>
>   (thing (inherit x) (name \"bar\"))
>
> This expression returns a new object equal to 'x' except for its 'name'
> field and its 'loc' field---the latter is marked as \"innate\", so it is not
> inherited."
>
>
> (Argh, I do not know how to read/display the docstring from the REPL,
> another annoying* story. :-))

Do you know if the above guix records are in the guix manual?  If not,
I'll probably add them.

>
>> This is not possible with (srfi sfri-9)
>>
>> (use-modules (srfi srfi-9))
>>
>> (define-record-type <employee>
>>   (make-employee name age (make-employeee 5 5 5))
>>   employee?
>>   (name    employee-name)
>>   (age     employee-age    set-employee-age!)
>>   (salary  employee-salary set-employee-salary!))
>
> Well, ’(guix records)’ allows to do more than ’(srfi srfi-9)’.

Amen for that!  (guix records) are awesome!

> Aside, I
> am not convinced that this latter snippet is similar than the former
> previous one.

I was just trying to see if I could produce a similar issue for the
guile compiler via only using (srfi srfi-9).  Apparently I cannot.

> Cheers,
> simon
>
> *annoying REPL, I get:
>
> scheme@(guix-user)> ,describe define-record-type*
> While executing meta-command:
> Syntax error:
> unknown file:79:10: source expression failed to match any pattern in form define-record-type*

try

(use-modules (guix records))...though you probably already did that.

What about

,m (guix records)  ?

-- 
Joshua Branson (jab in #guix)
Sent from Emacs and Gnus
  https://gnucode.me
  https://video.hardlimit.com/accounts/joshua_branson/video-channels
  https://propernaming.org
  "You can have whatever you want, as long as you help
enough other people get what they want." - Zig Ziglar
  




Information forwarded to bug-guix <at> gnu.org:
bug#51383; Package guix. (Mon, 25 Oct 2021 11:22:02 GMT) Full text and rfc822 format available.

Message #14 received at 51383 <at> debbugs.gnu.org (full text, mbox):

From: zimoun <zimon.toutoune <at> gmail.com>
To: Joshua Branson <jbranso <at> dismail.de>
Cc: 51383 <at> debbugs.gnu.org
Subject: Re: bug#51383: noobie way of incorrectly using (guix records)
Date: Mon, 25 Oct 2021 13:21:40 +0200
Hi,

On Mon, 25 Oct 2021 at 05:36, Joshua Branson <jbranso <at> dismail.de> wrote:

> Do you know if the above guix records are in the guix manual?  If not,
> I'll probably add them.

Nothing seems documented in the manual.  That’s why I have been gone to
the docstring. :-)


Cheers,
simon




Reply sent to Joshua Branson <jbranso <at> dismail.de>:
You have taken responsibility. (Wed, 27 Oct 2021 18:01:02 GMT) Full text and rfc822 format available.

Notification sent to Joshua Branson <jbranso <at> dismail.de>:
bug acknowledged by developer. (Wed, 27 Oct 2021 18:01:03 GMT) Full text and rfc822 format available.

Message #19 received at 51383-done <at> debbugs.gnu.org (full text, mbox):

From: Joshua Branson <jbranso <at> dismail.de>
To: 51383-done <at> debbugs.gnu.org
Date: Wed, 27 Oct 2021 14:00:42 -0400
Bug will not be fixed.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 25 Nov 2021 12:24:10 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 207 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.