unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: larsi@gnus.org, 38252@debbugs.gnu.org
Subject: bug#38252: 27.0.50; Gnus server definitions and generic function specializers
Date: Sun, 17 Nov 2019 19:18:30 -0800	[thread overview]
Message-ID: <87imnhan3t.fsf@ericabrahamsen.net> (raw)
In-Reply-To: <jwv1ru69cc0.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sun, 17 Nov 2019 21:03:00 -0500")


On 11/17/19 21:03 PM, Stefan Monnier wrote:
>> I'm ccing you directly because I suspect you're the only one who knows
>> the answers to my questions :)
>
> I doubt it, there's a lot of people around here more familiar with
> CLOS-style programming than I.
>
>> --8<---------------cut here---------------start------------->8---
>> gnus-int.el:
>> (cl-defgeneric gnus-request-list (server)
>>   "Docs and stuff.")
>>
>> (cl-defmethod gnus-request-list ((server gnus-server-legacy))
>>   (funcall (gnus-get-function server 'request-list)
>> 	   (nth 1 server)))
>
> Why not just:
>
>     (cl-defmethod gnus-request-list (server)
>       (funcall (gnus-get-function server 'request-list)
>     	       (nth 1 server)))
>
> which means "use it as a fallback".  The downside is that it will be
> used for non-legacy servers if there is no specific implementation for
> that server, but presumably you can detect it and signal an appropriate
> error somewhere inside gnus-get-function.
>
>> What I'm trying to do is fairly simple: if the argument is a list, and
>> the head of the list is a symbol that can be assoc'd into
>> `nnoo-definition-alist', and the second element is a string, then it's a
>> gnus-legacy-server.
>
> Why not just use a `cons` specializer?
>
> IIUC all the non-legacy servers will use structs, so you don't need to
> use a specializer that's so specific that it has to check "if the
> argument is a list, and the head of the list is a symbol that can be
> assoc'd into `nnoo-definition-alist', and the second element is
> a string".

Okay, perhaps I was overthinking this. I don't want to assume that the
fallback is an old-style server (we might want to use the fallback for
other purposes), but you're right that 'cons is pretty much sufficient.
If anyone feeds a cons value into a Gnus server interface function that
*isn't* a server definition, that falls into "serves you right"
territory.

But just so I don't feel like I wasted my afternoon: how *would* one
write the generalizer I'm talking about?

Thanks,
Eric





  reply	other threads:[~2019-11-18  3:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-17 22:31 bug#38252: 27.0.50; Gnus server definitions and generic function specializers Eric Abrahamsen
2019-11-18  2:03 ` Stefan Monnier
2019-11-18  3:18   ` Eric Abrahamsen [this message]
2019-11-18  4:36     ` Stefan Monnier
2019-11-18 20:43       ` Eric Abrahamsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87imnhan3t.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=38252@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).