GNU bug report logs -
#59221
(file-exists? #f) raises an exception
Previous Next
Reported by: Joshua Branson <jbranso <at> dismail.de>
Date: Sat, 12 Nov 2022 17:50:01 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 59221 in the body.
You can then email your comments to 59221 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-guile <at> gnu.org
:
bug#59221
; Package
guile
.
(Sat, 12 Nov 2022 17:50:01 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-guile <at> gnu.org
.
(Sat, 12 Nov 2022 17:50:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hello you lovely guile people!
This bug is so simple the subject line says it all!
file-exists? is a predicate, but
#+BEGIN_SRC scheme
(file-exists? #f)
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
In procedure stat: Wrong type argument in position 1 (expecting open file port): #f
Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
#+END_SRC
I will shortly tag this as "easy". Can you lovely maintainers give me
about a week to try to fix this myself?
Thanks,
Joshua
avid fantany reader
Information forwarded
to
bug-guile <at> gnu.org
:
bug#59221
; Package
guile
.
(Sat, 12 Nov 2022 17:59:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 59221 <at> debbugs.gnu.org (full text, mbox):
> Le 12 nov. 2022 à 18:50, Joshua Branson via Bug reports for GUILE, GNU's Ubiquitous Extension Language <bug-guile <at> gnu.org> a écrit :
>
>
> Hello you lovely guile people!
>
> This bug is so simple the subject line says it all!
>
> file-exists? is a predicate, but
>
> #+BEGIN_SRC scheme
> (file-exists? #f)
> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
> In procedure stat: Wrong type argument in position 1 (expecting open file port): #f
>
> Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
> #+END_SRC
>
> I will shortly tag this as "easy". Can you lovely maintainers give me
> about a week to try to fix this myself?
>
> Thanks,
>
> Joshua
> avid fantany reader
What’s the problem here?
It is normal for predicates to be defined only on certain types. You will find the same with positive?, string-null? and the like.
Regards,
Jean
Information forwarded
to
bug-guile <at> gnu.org
:
bug#59221
; Package
guile
.
(Sun, 13 Nov 2022 02:16:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 59221 <at> debbugs.gnu.org (full text, mbox):
November 12, 2022 12:58 PM, "Jean Abou Samra" <jean <at> abou-samra.fr> wrote:
>> Le 12 nov. 2022 à 18:50, Joshua Branson via Bug reports for GUILE, GNU's Ubiquitous Extension
>> Language <bug-guile <at> gnu.org> a écrit :
>>
>> Hello you lovely guile people!
>>
>> This bug is so simple the subject line says it all!
>>
>> file-exists? is a predicate, but
>>
>> #+BEGIN_SRC scheme
>> (file-exists? #f)
>> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
>> In procedure stat: Wrong type argument in position 1 (expecting open file port): #f
>>
>> Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
>> #+END_SRC
>>
>> I will shortly tag this as "easy". Can you lovely maintainers give me
>> about a week to try to fix this myself?
>>
>> Thanks,
>>
>> Joshua
>> avid fantany reader
>
> What’s the problem here?
>
> It is normal for predicates to be defined only on certain types. You will find the same with
> positive?, string-null? and the like.
Perhaps I am just being really pedantic. I asked in the #guile irc chat if a predicate should
be able to raise an exception. The answer I was given was no.
Admittedly I did not stay in the channel for long, and I quickly filed this bug report.
Naively, it just feel like it (file-exists? #f) should return #f.
Would there be an objection to changing the definition of file-exists to
(define (file-exists file)
(and (string? file)
(old-file-exists-code file)))
Thanks,
Joshua
>
> Regards,
> Jean
Information forwarded
to
bug-guile <at> gnu.org
:
bug#59221
; Package
guile
.
(Sun, 13 Nov 2022 06:45:02 GMT)
Full text and
rfc822 format available.
Message #14 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Sun, Nov 13, 2022 at 02:15:43AM +0000, jbranso--- via Bug reports for GUILE, GNU's Ubiquitous Extension Language wrote:
> November 12, 2022 12:58 PM, "Jean Abou Samra" <jean <at> abou-samra.fr> wrote:
>
> >> Le 12 nov. 2022 à 18:50, Joshua Branson via Bug reports for GUILE, GNU's Ubiquitous Extension
> >> Language <bug-guile <at> gnu.org> a écrit :
> >>
> >> Hello you lovely guile people!
> >>
> >> This bug is so simple the subject line says it all!
[file-exists? raises exception on #f]
[...]
> > It is normal for predicates to be defined only on certain types. You will find the same with
> > positive?, string-null? and the like.
>
> Perhaps I am just being really pedantic. I asked in the #guile irc chat if a predicate should
> be able to raise an exception. The answer I was given was no.
You both have a point. Checking for existing predicates with a
longer tradition, though:
scheme@(guile-user)> (exact? "mumble")
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
In procedure exact?: Wrong type argument in position 1: "mumble"
seems to support Jean Abu's position that it is more customary to
raise for an argument of the wrong type. Also `string<?', etc.
do this. That seems to be the consensus.
Cheers
--
t
[signature.asc (application/pgp-signature, inline)]
Information forwarded
to
bug-guile <at> gnu.org
:
bug#59221
; Package
guile
.
(Sun, 13 Nov 2022 10:35:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 59221 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Le 13/11/2022 à 07:44, tomas <at> tuxteam.de a écrit :
> You both have a point. Checking for existing predicates with a
> longer tradition, though:
>
> scheme@(guile-user)> (exact? "mumble")
> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
> In procedure exact?: Wrong type argument in position 1: "mumble"
>
> seems to support Jean Abu's position that it is more customary to
> raise for an argument of the wrong type. Also `string<?', etc.
> do this. That seems to be the consensus.
Yes. I am not sure where the people in the Guile IRC got the idea
that a predicate shouldn't raise an exception. Lots of predicates in
Guile do, and that is very helpful because it catches mistakes.
> Naively, it just feel like it (file-exists? #f) should return #f.
Why?
> Would there be an objection to changing the definition of file-exists to
>
> (define (file-exists file)
> (and (string? file)
> (old-file-exists-code file)))
It would be inconsistent with the rest of Guile and I don't
see what it would help with.
Best,
Jean
[OpenPGP_signature (application/pgp-signature, attachment)]
Information forwarded
to
bug-guile <at> gnu.org
:
bug#59221
; Package
guile
.
(Wed, 16 Nov 2022 15:28:01 GMT)
Full text and
rfc822 format available.
Message #20 received at 59221 <at> debbugs.gnu.org (full text, mbox):
Jean Abou Samra <jean <at> abou-samra.fr> writes:
> Le 13/11/2022 à 07:44, tomas <at> tuxteam.de a écrit :
>> You both have a point. Checking for existing predicates with a
>> longer tradition, though:
>>
>> scheme@(guile-user)> (exact? "mumble")
>> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
>> In procedure exact?: Wrong type argument in position 1: "mumble"
>>
>> seems to support Jean Abu's position that it is more customary to
>> raise for an argument of the wrong type. Also `string<?', etc.
>> do this. That seems to be the consensus.
>
>
> Yes. I am not sure where the people in the Guile IRC got the idea
> that a predicate shouldn't raise an exception. Lots of predicates in
> Guile do, and that is very helpful because it catches mistakes.
>
>
>> Naively, it just feel like it (file-exists? #f) should return #f.
>
>
> Why?
>
hmmm, somehow I missed your response. I guess for my simple use case,
it just made more sense. I am defining a service for guix that asks for
user input. If the user doesn't type in input, the default value was
#f.
That's fine. Thanks for all's replies. I'll go ahead and close this
bug!
Thanks!
>
>
>> Would there be an objection to changing the definition of file-exists to
>>
>> (define (file-exists file)
>> (and (string? file)
>> (old-file-exists-code file)))
>
>
>
> It would be inconsistent with the rest of Guile and I don't
> see what it would help with.
>
> Best,
> Jean
bug closed, send any further explanations to
59221 <at> debbugs.gnu.org and Joshua Branson <jbranso <at> dismail.de>
Request was from
Joshua Branson <jbranso <at> dismail.de>
to
control <at> debbugs.gnu.org
.
(Wed, 16 Nov 2022 15:31:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 15 Dec 2022 12:24:06 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year and 130 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.