From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Generic autoloading? [Was Patch: perform autoloading when docs is missing from autoload object] Date: Fri, 17 Sep 2021 15:36:33 -0400 Message-ID: References: <2ABC3C0C-CBF7-44D9-B498-B548F820B125@mit.edu> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27692"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Arthur Miller , "emacs-devel@gnu.org" To: Qiantan Hong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Sep 17 21:37:21 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mRJfk-00070O-Lj for ged-emacs-devel@m.gmane-mx.org; Fri, 17 Sep 2021 21:37:20 +0200 Original-Received: from localhost ([::1]:34260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mRJfj-0007G2-3n for ged-emacs-devel@m.gmane-mx.org; Fri, 17 Sep 2021 15:37:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50346) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mRJfA-0006aG-5U for emacs-devel@gnu.org; Fri, 17 Sep 2021 15:36:44 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:30892) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mRJf3-0003x5-ME for emacs-devel@gnu.org; Fri, 17 Sep 2021 15:36:42 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id BE09710018A; Fri, 17 Sep 2021 15:36:35 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id EF053100054; Fri, 17 Sep 2021 15:36:33 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1631907393; bh=CbltS5LqzMjJEpDL8+GW7JbyUwl1WHVTZezTrvWjm/Q=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=mpFONQx4Q0JuhrolDK4faC0zgJCSo/L3PvLxIEPitdlbL0+UDx7NnkTOKCkIwakhS XC9wwoY/CjSchnnCvSrY5Qbp3GQW8g1/lG1EBriIzX9DKhXtM3gaZF0L8j3BIhRNVT dO5Xd5Sn7uTHt3fnPZW1odiTAjocpjwxIdIRKPENooaci5yewkmPaxJw5WY1/dagng d5sRJZNudh8hwCoL/1Su0cvwH0F55UtaDhq8eGCzRlKvBhSH2/Fc+oPgS4f/FSh9YJ U768A+3nzW8PP2+GgmKviZwsaOwu2KUBgOuHwtzHsG1Aw3GZYFO2t44tHLitAsSwld 3+wW6MJkgJELQ== Original-Received: from ceviche (modemcable004.216-203-24.mc.videotron.ca [24.203.216.4]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id BA8AB1202BC; Fri, 17 Sep 2021 15:36:33 -0400 (EDT) In-Reply-To: <2ABC3C0C-CBF7-44D9-B498-B548F820B125@mit.edu> (Qiantan Hong's message of "Fri, 17 Sep 2021 16:56:34 +0000") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:274928 Archived-At: > Just in case, is it possible to provide a generic autoload mechanism > that run arbitrary function to load the missing function, > instead of hardcoded to basically a REQUIRE? I think if it doesn't end up loading a file, and isn't bound to the `symbol-function` cell of a symbol, then it's probably too different from our autoloads to be worth trying to shoehorn it into the existing system. > Currently I can fake it with a closure that knows where it is > and replace itself once called. I think the fix is to remove the word "fake" in the description ;-) > But it feels like reimplementing the same thing twice. I haven't looked at your code, but if what you fetch lazily is itself a function, then I suspect that your "faking code" is clean, short, and reliable, and there isn't much to share with the autoload code (other than a philosophical similarity). > (I think current autoload can also be implemented in pure Elisp > in this way, More or less, yes (tho it gets more costly in terms of heap usage). Also, we have accrued various subtle details that are inconvenient to mimic (e.g. various places call `autoload-do-load` manually rather than just calling the function in order to get a bit more control over what happens when). Stefan