unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: [Emacs-diffs] master ef75c3b: Optimize `file-equal-p' and `file-in-directory-p' in Tramp
       [not found] ` <E1ZwSwD-0005m3-U8@vcs.savannah.gnu.org>
@ 2015-11-11 14:40   ` Stefan Monnier
  2015-11-11 15:38     ` Michael Albinus
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2015-11-11 14:40 UTC (permalink / raw)
  To: emacs-devel; +Cc: Michael Albinus

> +  (when (string-equal
> +	 (file-remote-p (expand-file-name filename1))
> +	 (file-remote-p (expand-file-name filename2)))

The above args to string-equal aren't always strings: why not use
`equal' instead?
(string-equal nil "nil") is non-nil, so I think the code will work
correctly but only because file-remote-p should hopefully never return
"nil".


        Stefan



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

* Re: [Emacs-diffs] master ef75c3b: Optimize `file-equal-p' and `file-in-directory-p' in Tramp
  2015-11-11 14:40   ` [Emacs-diffs] master ef75c3b: Optimize `file-equal-p' and `file-in-directory-p' in Tramp Stefan Monnier
@ 2015-11-11 15:38     ` Michael Albinus
  2015-11-11 16:07       ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Albinus @ 2015-11-11 15:38 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> +  (when (string-equal
>> +	 (file-remote-p (expand-file-name filename1))
>> +	 (file-remote-p (expand-file-name filename2)))
>
> The above args to string-equal aren't always strings: why not use
> `equal' instead?
> (string-equal nil "nil") is non-nil, so I think the code will work
> correctly but only because file-remote-p should hopefully never return
> "nil".

file-remote-p never returns "nil". It returns either the remote prefix
of a file name (a string), or nil.

>         Stefan

Best regards, Michael.



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

* Re: [Emacs-diffs] master ef75c3b: Optimize `file-equal-p' and `file-in-directory-p' in Tramp
  2015-11-11 15:38     ` Michael Albinus
@ 2015-11-11 16:07       ` Stefan Monnier
  2015-11-11 16:46         ` Michael Albinus
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2015-11-11 16:07 UTC (permalink / raw)
  To: Michael Albinus; +Cc: emacs-devel

>>> +  (when (string-equal
>>> +	 (file-remote-p (expand-file-name filename1))
>>> +	 (file-remote-p (expand-file-name filename2)))
>> 
>> The above args to string-equal aren't always strings: why not use
>> `equal' instead?
>> (string-equal nil "nil") is non-nil, so I think the code will work
>> correctly but only because file-remote-p should hopefully never return
>> "nil".

> file-remote-p never returns "nil".

That's what I meant by "I think the code will work correctly but only
because ...".

> It returns either the remote prefix of a file name (a string), or nil.

Can you really prove that "the remote prefix of a file name" will never
be "nil"?  Remember: your proof can only assume that one of filename1 or
filename2 is a Tramp file name (the other can be anything at all,
possibly matching any weird file-name-handler).

I think rather than try to prove it, it's easier to use `equal' and move on.


        Stefan



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

* Re: [Emacs-diffs] master ef75c3b: Optimize `file-equal-p' and `file-in-directory-p' in Tramp
  2015-11-11 16:07       ` Stefan Monnier
@ 2015-11-11 16:46         ` Michael Albinus
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Albinus @ 2015-11-11 16:46 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> It returns either the remote prefix of a file name (a string), or nil.
>
> Can you really prove that "the remote prefix of a file name" will never
> be "nil"?  Remember: your proof can only assume that one of filename1 or
> filename2 is a Tramp file name (the other can be anything at all,
> possibly matching any weird file-name-handler).

A Tramp file name will never return "nil" for the remote prefix. If the
other file is plagued by a weird file name handler which returns "nil":
no problem. string-equal returns nil, and that's what's expected.

> I think rather than try to prove it, it's easier to use `equal' and move on.

If you feel better, change it. I don't care too much about.

>         Stefan

Best regards, Michael.



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

end of thread, other threads:[~2015-11-11 16:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20151111104737.22161.11802@vcs.savannah.gnu.org>
     [not found] ` <E1ZwSwD-0005m3-U8@vcs.savannah.gnu.org>
2015-11-11 14:40   ` [Emacs-diffs] master ef75c3b: Optimize `file-equal-p' and `file-in-directory-p' in Tramp Stefan Monnier
2015-11-11 15:38     ` Michael Albinus
2015-11-11 16:07       ` Stefan Monnier
2015-11-11 16:46         ` Michael Albinus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).