GNU bug report logs - #59221
(file-exists? #f) raises an exception

Previous Next

Package: guile;

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.

Full log


View this message in rfc822 format

From: Joshua Branson <jbranso <at> dismail.de>
To: Jean Abou Samra <jean <at> abou-samra.fr>
Cc: 59221 <at> debbugs.gnu.org, tomas <at> tuxteam.de
Subject: bug#59221: (file-exists? #f) raises an exception
Date: Wed, 16 Nov 2022 10:27:34 -0500
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




This bug report was last modified 2 years and 183 days ago.

Previous Next


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