[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] lisp/files.el: Add `file-name-set-extension`

From: Colin Woodbury
Subject: Re: [PATCH] lisp/files.el: Add `file-name-set-extension`
Date: Wed, 09 Jun 2021 13:54:23 -0700
User-agent: Cyrus-JMAP/3.5.0-alpha0-519-g27a961944e-fm-20210531.001-g27a96194

Hi all, thanks for the input. I've revised the patch to account for empty strings and for filenames that look like directories (i.e. that end in a slash).

I've also begun the copyright assignment process, since adding the unit tests lengthened the patch past the critical line count.

As for the naming of `set-extension`, the best I can think of as an alternative would be `with-extension` as a dual to `sans-extension`, although I think `set` still signals the intent well enough. I'll defer to others here.


On Fri, 4 Jun 2021, at 06:23, Mattias EngdegÄrd wrote:
4 juni 2021 kl. 15.08 skrev Philipp <p.stephani2@gmail.com>:

> Likewise, change the docstring to clarify that a new string is returned.

Actually we usually don't bother saying that a function creates a new string unless this is guaranteed and somehow important, since we don't encourage string mutation anyway. For example, functions are usually allowed to return an unchanged argument string if that would make sense.

Conversely, only functions that do mutate strings need to mention that fact. By default, a user should be able to assume that no string mutation takes place.

I fully agree with the rest of Philipp's excellent points.

Attachment: file-name-set-extension.patch
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]