* Re: master 6e796b5: Stop project-root from going into infinite recursion
[not found] ` <20210317164928.C2C11209AA@vcs0.savannah.gnu.org>
@ 2021-03-17 21:33 ` Stefan Monnier
2021-03-17 21:52 ` Dmitry Gutov
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2021-03-17 21:33 UTC (permalink / raw)
To: emacs-devel; +Cc: Dmitry Gutov
> @@ -215,7 +217,9 @@ It usually contains the main build file, dependencies
> configuration file, etc. Though neither is mandatory.
>
> The directory name must be absolute."
> - (car (project-roots project)))
> + (if project--within-roots-fallback
> + (signal 'cl-no-applicable-method (list 'project-root project))
> + (car (project-roots project))))
I think `cl-call-next-method` is a better choice.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: master 6e796b5: Stop project-root from going into infinite recursion
2021-03-17 21:33 ` master 6e796b5: Stop project-root from going into infinite recursion Stefan Monnier
@ 2021-03-17 21:52 ` Dmitry Gutov
2021-03-17 22:29 ` Stefan Monnier
0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Gutov @ 2021-03-17 21:52 UTC (permalink / raw)
To: Stefan Monnier, emacs-devel
On 17.03.2021 23:33, Stefan Monnier wrote:
> I think `cl-call-next-method` is a better choice.
If you're sure about that.
The idea here was, some prospective backend author might look at the
error symbol and make a decision on how to fix the problem based on it.
And "you need to implement this method" seems better expressed with "No
applicable method" rather than with "No next method".
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: master 6e796b5: Stop project-root from going into infinite recursion
2021-03-17 21:52 ` Dmitry Gutov
@ 2021-03-17 22:29 ` Stefan Monnier
2021-03-18 0:37 ` Dmitry Gutov
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2021-03-17 22:29 UTC (permalink / raw)
To: Dmitry Gutov; +Cc: emacs-devel
>> I think `cl-call-next-method` is a better choice.
> If you're sure about that.
> The idea here was, some prospective backend author might look at the error
> symbol and make a decision on how to fix the problem based on it.
> And "you need to implement this method" seems better expressed with "No
> applicable method" rather than with "No next method".
I see. I consider the difference between the two as an error in CLOS,
but I didn't have the courage to remove it in cl-generic.el ;-)
FWIW, you could also get what you want with something like:
(cl-defgeneric project-root (project)
"Return root directory of the current project.
It usually contains the main build file, dependencies
configuration file, etc. Though neither is mandatory.
The directory name must be absolute.")
(cl-defmethod project-root (project
&context (project--within-roots-fallback
(eql nil)))
(car (project-roots project)))
This way there indeed won't be any applicable method when
project--within-roots-fallback is non-nil ;-)
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: master 6e796b5: Stop project-root from going into infinite recursion
2021-03-17 22:29 ` Stefan Monnier
@ 2021-03-18 0:37 ` Dmitry Gutov
0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Gutov @ 2021-03-18 0:37 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
On 18.03.2021 00:29, Stefan Monnier wrote:
> I see. I consider the difference between the two as an error in CLOS,
> but I didn't have the courage to remove it in cl-generic.el;-)
I'm no CLOS expect, so I was choosing purely on how the names sound.
> FWIW, you could also get what you want with something like:
>
> (cl-defgeneric project-root (project)
> "Return root directory of the current project.
>
> It usually contains the main build file, dependencies
> configuration file, etc. Though neither is mandatory.
>
> The directory name must be absolute.")
>
> (cl-defmethod project-root (project
> &context (project--within-roots-fallback
> (eql nil)))
> (car (project-roots project)))
>
> This way there indeed won't be any applicable method when
> project--within-roots-fallback is non-nil;-)
That's a neat suggestion, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-03-18 0:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20210317164927.28196.12402@vcs0.savannah.gnu.org>
[not found] ` <20210317164928.C2C11209AA@vcs0.savannah.gnu.org>
2021-03-17 21:33 ` master 6e796b5: Stop project-root from going into infinite recursion Stefan Monnier
2021-03-17 21:52 ` Dmitry Gutov
2021-03-17 22:29 ` Stefan Monnier
2021-03-18 0:37 ` Dmitry Gutov
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).