all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stephen Leake <stephen_leake@stephe-leake.org>
To: emacs-devel <emacs-devel@gnu.org>
Subject: Re: autoload cl-defstruct constructor?
Date: Thu, 05 Sep 2019 16:36:09 -0700	[thread overview]
Message-ID: <86ef0u8geu.fsf@stephe-leake.org> (raw)
In-Reply-To: <jwvk1anopjn.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Wed, 04 Sep 2019 15:03:42 -0400")

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

>> I tried adding an autoload cookie to the cl-defstruct. That almost
>> works, but update-directory-autoloads doesn't respect the order implied
>> by :include, so wisi-compiler is declared in autoloads.el after it is
>> needed.
>
> Could you give details about this ordering problem?

Hmm. Attempting to reproduce this, I ran into a different but related
problem.

If I add an autoload cookie to a cl-defstruct, running
update-directory-autoloads on the above gives:

---

;;; Generated autoloads from gnat-core.el

(cl-defstruct gnat-compiler "\
Used with wisi-compiler-* generic functions." gpr-file run-buffer-name project-path target runtime gnat-stub-opts gnat-stub-cargs)

---

There is no "autoload" call, as there would be with a normal function.
So even though 'make-gnat-compiler' is defined, calling it does not load
gnat-core.el, so no other functions are defined.

So more autoloads are required. Not really a problem, but unexpected.

> It sounds like a bug (tho fixing it will probably not help you in the
> short-run if you need your solution to work in Emacs-26).

The files are included in autoloads.el in file name alphabetical order
(although there do seem to be exceptions?). So with my real code, I get:

--- 

;;; Generated autoloads from ada-core.el

...

(cl-defstruct (ada-prj (:include wisi-prj) (:copier nil) (:constructor nil) (:constructor make-ada-prj (&key name compile-env (compiler-label ada-compiler) (xref-label ada-xref-tool) source-path plist file-pred &aux (compiler (ada-prj-make-compiler compiler-label)) (xref (ada-prj-make-xref xref-label))))) plist)

...

;;; Generated autoloads from wisi-prj.el

(cl-defstruct wisi-prj name compile-env file-env compiler xref (case-exception-files nil) (case-full-exceptions 'nil) (case-partial-exceptions 'nil) source-path file-pred)


---

At the point where 'ada-prj' is declared, 'wisi-prj' is unknown.

I can create a simple reproducer for a bug report, if you think that's
warrented.

For now, I'll try the renamed constructor approach.

-- 
-- Stephe



  reply	other threads:[~2019-09-05 23:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-04 18:53 autoload cl-defstruct constructor? Stephen Leake
2019-09-04 19:03 ` Stefan Monnier
2019-09-05 23:36   ` Stephen Leake [this message]
2019-09-06 12:47     ` Stefan Monnier
2019-09-06 22:25       ` Stephen Leake
2019-09-07 14:29         ` Stefan Monnier
2019-09-09 19:12           ` Stephen Leake
2019-09-09 19:35             ` Stephen Leake
2019-09-09 21:38             ` Stefan Monnier

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

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

  git send-email \
    --in-reply-to=86ef0u8geu.fsf@stephe-leake.org \
    --to=stephen_leake@stephe-leake.org \
    --cc=emacs-devel@gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.