unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#59221: (file-exists? #f) raises an exception
@ 2022-11-12 17:49 Joshua Branson via Bug reports for GUILE, GNU's Ubiquitous Extension Language
  2022-11-12 17:57 ` Jean Abou Samra
  2022-11-13  2:15 ` jbranso--- via Bug reports for GUILE, GNU's Ubiquitous Extension Language
  0 siblings, 2 replies; 6+ messages in thread
From: Joshua Branson via Bug reports for GUILE, GNU's Ubiquitous Extension Language @ 2022-11-12 17:49 UTC (permalink / raw)
  To: 59221


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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#59221: (file-exists? #f) raises an exception
  2022-11-12 17:49 bug#59221: (file-exists? #f) raises an exception Joshua Branson via Bug reports for GUILE, GNU's Ubiquitous Extension Language
@ 2022-11-12 17:57 ` Jean Abou Samra
  2022-11-13  2:15 ` jbranso--- via Bug reports for GUILE, GNU's Ubiquitous Extension Language
  1 sibling, 0 replies; 6+ messages in thread
From: Jean Abou Samra @ 2022-11-12 17:57 UTC (permalink / raw)
  To: Joshua Branson; +Cc: 59221



> Le 12 nov. 2022 à 18:50, Joshua Branson via Bug reports for GUILE, GNU's Ubiquitous Extension Language <bug-guile@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








^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#59221: (file-exists? #f) raises an exception
  2022-11-12 17:49 bug#59221: (file-exists? #f) raises an exception Joshua Branson via Bug reports for GUILE, GNU's Ubiquitous Extension Language
  2022-11-12 17:57 ` Jean Abou Samra
@ 2022-11-13  2:15 ` jbranso--- via Bug reports for GUILE, GNU's Ubiquitous Extension Language
  2022-11-13  6:44   ` tomas
  1 sibling, 1 reply; 6+ messages in thread
From: jbranso--- via Bug reports for GUILE, GNU's Ubiquitous Extension Language @ 2022-11-13  2:15 UTC (permalink / raw)
  To: Jean Abou Samra; +Cc: 59221

November 12, 2022 12:58 PM, "Jean Abou Samra" <jean@abou-samra.fr> wrote:

>> Le 12 nov. 2022 à 18:50, Joshua Branson via Bug reports for GUILE, GNU's Ubiquitous Extension
>> Language <bug-guile@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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#59221: (file-exists? #f) raises an exception
  2022-11-13  2:15 ` jbranso--- via Bug reports for GUILE, GNU's Ubiquitous Extension Language
@ 2022-11-13  6:44   ` tomas
  2022-11-13 10:34     ` Jean Abou Samra
  0 siblings, 1 reply; 6+ messages in thread
From: tomas @ 2022-11-13  6:44 UTC (permalink / raw)
  To: 59221

[-- Attachment #1: Type: text/plain, Size: 1280 bytes --]

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@abou-samra.fr> wrote:
> 
> >> Le 12 nov. 2022 à 18:50, Joshua Branson via Bug reports for GUILE, GNU's Ubiquitous Extension
> >> Language <bug-guile@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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#59221: (file-exists? #f) raises an exception
  2022-11-13  6:44   ` tomas
@ 2022-11-13 10:34     ` Jean Abou Samra
  2022-11-16 15:27       ` Joshua Branson via Bug reports for GUILE, GNU's Ubiquitous Extension Language
  0 siblings, 1 reply; 6+ messages in thread
From: Jean Abou Samra @ 2022-11-13 10:34 UTC (permalink / raw)
  To: tomas, 59221


[-- Attachment #1.1: Type: text/plain, Size: 1099 bytes --]

Le 13/11/2022 à 07:44, tomas@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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#59221: (file-exists? #f) raises an exception
  2022-11-13 10:34     ` Jean Abou Samra
@ 2022-11-16 15:27       ` Joshua Branson via Bug reports for GUILE, GNU's Ubiquitous Extension Language
  0 siblings, 0 replies; 6+ messages in thread
From: Joshua Branson via Bug reports for GUILE, GNU's Ubiquitous Extension Language @ 2022-11-16 15:27 UTC (permalink / raw)
  To: Jean Abou Samra; +Cc: 59221, tomas

Jean Abou Samra <jean@abou-samra.fr> writes:

> Le 13/11/2022 à 07:44, tomas@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





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-11-16 15:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-12 17:49 bug#59221: (file-exists? #f) raises an exception Joshua Branson via Bug reports for GUILE, GNU's Ubiquitous Extension Language
2022-11-12 17:57 ` Jean Abou Samra
2022-11-13  2:15 ` jbranso--- via Bug reports for GUILE, GNU's Ubiquitous Extension Language
2022-11-13  6:44   ` tomas
2022-11-13 10:34     ` Jean Abou Samra
2022-11-16 15:27       ` Joshua Branson via Bug reports for GUILE, GNU's Ubiquitous Extension Language

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).