bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#50499: 28.0.50; project.el: Root of current project


From: Dmitry Gutov
Subject: bug#50499: 28.0.50; project.el: Root of current project
Date: Fri, 10 Sep 2021 15:16:56 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0

On 10.09.2021 08:26, Augusto Stoffel wrote:
I guess most uses of `project-root' will be of the form

     (when-let ((p (project-current)))
        (project-root p))

Or at least this is true in the case of an user who is quickly defining
a shortcut command in their config.

Wouldn't it make sense to make the PROJECT argument of `project-root'
optional, giving the above result when omitted?

Given the way it this works, it would need to be a helper function.

IIUC cl-defmethod does not support default values for arguments, and if it did, we'd have to have an implementation of project-root, etc, for nil argument. Which is a bad idea because someone else might not want to simply do nothing when there is no project found, and our type system would then fail to help them notice that.

I don't mind adding said helper (naming suggestions welcome), but the way things work now seems fine to me already. Either you have:

  (project-root (project-current t))

where there is no risk of returning nil, and thus no need for when-let,
or you call (project-current) first, check it for nil, and then _probably_ use some other fallbacks. If you don't have fallbacks, then the other approach seems better, no?





reply via email to

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