bug#59221: (file-exists? #f) raises an exception

jbranso--- via "Bug reports for GUILE, GNU's Ubiquitous Extension Language" <[email protected]>
Newsgroups gmane.lisp.guile.bugs
Message-ID <[email protected]>
November 12, 2022 12:58 PM, "Jean Abou Samra" <[email protected]> wrote:

>> Le 12 nov. 2022 à 18:50, Joshua Branson via Bug reports for GUILE, GNU's Ubiquitous Extension
>> Language <[email protected]> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.