Re: better error messages through assertions

2022-04-05 Thread Ludovic Courtès
Hi, Philip McGrath skribis: > On 3/30/22 09:28, Andy Wingo wrote: >> Too bad about all that other crap about checking whether the index >> is in >> range and the field is boxed or not, though :-/ Probably there is a >> better design... >> Andy > > For the index-out-of-range part, when I saw `re

Re: better error messages through assertions

2022-04-01 Thread Philip McGrath
Hi, On 3/30/22 05:37, Ludovic Courtès wrote: What is the preferred mechanism for exceptions? For Guix code, SRFI-34/35. Likewise, what record system should I use? SRFI-9. (Perhaps we should put answers to these questions in the “Coding Style” section of the manual.) As I've looked mo

Re: better error messages through assertions

2022-04-01 Thread Philip McGrath
Hi, On 3/30/22 09:28, Andy Wingo wrote: Too bad about all that other crap about checking whether the index is in range and the field is boxed or not, though :-/ Probably there is a better design... Andy For the index-out-of-range part, when I saw `record-accessor`, I thought of it as simil

Re: better error messages through assertions

2022-04-01 Thread Ludovic Courtès
Hi, Andy Wingo skribis: > Here we see the first procedure which is the thunk that wraps the > expression. Then in the beginning of the procedure at L7 you can see > there is a check for struct?, which has to be dominated by a true > heap-object? check. Duplicate checks are elided. So if SRFI-

Re: better error messages through assertions

2022-03-30 Thread Andy Wingo
On Wed 30 Mar 2022 11:37, Ludovic Courtès writes: >> scheme@(guile-user)> (container-contents '()) >> ice-9/boot-9.scm:1685:16: In procedure raise-exception: >> In procedure struct-vtable: Wrong type argument in position 1 > scheme@(guile-user)> ,use(srfi srfi-9) > scheme@(guile-user)> (define-re

Re: better error messages through assertions

2022-03-30 Thread Ludovic Courtès
Hi Philip, Philip McGrath skribis: > I'm thinking that a reasonable place to start might be to implement a > `contract->sanitizer` form that would allow using contracts to create > sanitizers, ideally with no changes to `(guix records)`. OK. I’d prefer if people who define record types could

Re: better error messages through assertions

2022-03-28 Thread Philip McGrath
Hi, On 3/7/22 05:13, Ludovic Courtès wrote: Hi Philip, Philip McGrath skribis: Racket's state-of-the-art contract system has many features and nuances. I *do not* think anyone should try to implement them all in one fell swoop. I'm hoping there's a way to implement your simple assertions wit

Re: better error messages through assertions

2022-03-07 Thread Ludovic Courtès
Hi Philip, Philip McGrath skribis: > Racket's state-of-the-art contract system has many features and nuances. I *do > not* think anyone should try to implement them all in one fell swoop. I'm > hoping there's a way to implement your simple assertions with only a modest > amount of overhead that

Re: better error messages through assertions

2022-02-28 Thread Philip McGrath
Hi, On Monday, February 28, 2022 7:59:02 AM EST Ludovic Courtès wrote: > Hi! > > Ricardo Wurmus skribis: > > Philip McGrath writes: > >> As a Racketeer, I think you're half way to reinventing contracts. > > > > Yes, I was in fact thinking of contracts, but shied away from mentioning > > them :

Re: better error messages through assertions

2022-02-28 Thread Maxim Cournoyer
Hello, Ludovic Courtès writes: > Ricardo Wurmus skribis: > >> Maxim Cournoyer writes: >> >>> I hear we now have "field sanitizers" on Guix records; without having >>> dug the details, it seems to be we could add a predicate validating the >>> input there? >> >> I don’t see how that would help

Re: better error messages through assertions

2022-02-28 Thread Ludovic Courtès
Ricardo Wurmus skribis: > Maxim Cournoyer writes: > >> I hear we now have "field sanitizers" on Guix records; without having >> dug the details, it seems to be we could add a predicate validating the >> input there? > > I don’t see how that would help here. In my example the service values > th

Re: better error messages through assertions

2022-02-28 Thread Ludovic Courtès
Hi! Ricardo Wurmus skribis: > Philip McGrath writes: > >> As a Racketeer, I think you're half way to reinventing contracts. > > Yes, I was in fact thinking of contracts, but shied away from mentioning > them :) The reason is that I think we can cover a lot of distance with > just a few simple

Re: better error messages through assertions

2022-02-26 Thread Maxim Cournoyer
Hi Ricardo, Ricardo Wurmus writes: > Maxim Cournoyer writes: > >> I hear we now have "field sanitizers" on Guix records; without having >> dug the details, it seems to be we could add a predicate validating the >> input there? > > I don’t see how that would help here. In my example the service

Re: better error messages through assertions

2022-02-26 Thread Ricardo Wurmus
Maxim Cournoyer writes: > I hear we now have "field sanitizers" on Guix records; without having > dug the details, it seems to be we could add a predicate validating the > input there? I don’t see how that would help here. In my example the service values themselves are all right. It’s a pro

Re: better error messages through assertions

2022-02-25 Thread Maxim Cournoyer
Hello Ricardo, Ricardo Wurmus writes: > Hi Guix, > > today on IRC someone reported an ugly error message when reconfiguring > their system: > > Backtrace: > 18 (primitive-load "/home/me/.config/guix/current/bin/…") > In guix/ui.scm: >2209:7 17 (run-guix . _) > 2172:10 16 (run-gui

Re: better error messages through assertions

2022-02-21 Thread Arun Isaac
Hi Ricardo, I too would like to see much better error checking for our services, though I don't know what the best way to achieve that is. Type checking alone may not be sufficient. All types in a configuration record could be valid, but some combination of field values in the record may not be

Re: better error messages through assertions

2022-02-15 Thread Ricardo Wurmus
Philip McGrath writes: > As a Racketeer, I think you're half way to reinventing contracts. Yes, I was in fact thinking of contracts, but shied away from mentioning them :) The reason is that I think we can cover a lot of distance with just a few simple assertions to avoid plowing ahead on bad

Re: better error messages through assertions

2022-02-15 Thread Philip McGrath
Hi, On 2/14/22 17:32, Ricardo Wurmus wrote: As you can probably tell easily by looking at this message, the “service” field of the operating system configuration looked something like this: (services (append (list a b c %desktop-services) #;oops)) instead of this (services (append (list

Re: better error messages through assertions

2022-02-15 Thread Maxime Devos
Ricardo Wurmus schreef op ma 14-02-2022 om 23:32 [+0100]: > I think we should add simple type checks, something like this: > [...] > > What do you think?  There are many different ways of implementing this > (a new variant of DEFINE that also accepts a type declaration, an assert > like above, a f

better error messages through assertions

2022-02-14 Thread Ricardo Wurmus
Hi Guix, today on IRC someone reported an ugly error message when reconfiguring their system: --8<---cut here---start->8--- Backtrace: 18 (primitive-load "/home/me/.config/guix/current/bin/…") In guix/ui.scm: 2209:7 17 (run-guix . _) 2172:10 16 (