From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Ordering in `source' property, and auto-loading of c-lang-defconsts Date: Sun, 31 Aug 2014 21:23:55 +0000 Message-ID: <20140831212355.GA4401@acm.acm> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1409520590 2917 80.91.229.3 (31 Aug 2014 21:29:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 31 Aug 2014 21:29:50 +0000 (UTC) Cc: Alan Mackenzie , Martin Stjernholm , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Aug 31 23:29:44 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XOCgy-0006TA-K6 for ged-emacs-devel@m.gmane.org; Sun, 31 Aug 2014 23:29:44 +0200 Original-Received: from localhost ([::1]:51107 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOCgy-00060l-79 for ged-emacs-devel@m.gmane.org; Sun, 31 Aug 2014 17:29:44 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35537) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOCgf-00060Q-Fp for emacs-devel@gnu.org; Sun, 31 Aug 2014 17:29:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XOCgX-0002Id-7z for emacs-devel@gnu.org; Sun, 31 Aug 2014 17:29:25 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:22086 helo=mail.muc.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOCgW-0002IF-UA for emacs-devel@gnu.org; Sun, 31 Aug 2014 17:29:17 -0400 Original-Received: (qmail 17486 invoked by uid 3782); 31 Aug 2014 21:29:14 -0000 Original-Received: from acm.muc.de (pD951A53F.dip0.t-ipconnect.de [217.81.165.63]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 31 Aug 2014 23:29:12 +0200 Original-Received: (qmail 6338 invoked by uid 1000); 31 Aug 2014 21:23:55 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 8.x X-Received-From: 193.149.48.1 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:173934 Archived-At: Hi, Stefan. On Thu, Aug 28, 2014 at 10:09:13AM -0400, Stefan Monnier wrote: > I'm trying to understand some of cc-defs.el and cc-langs.el code and > while there are very many questions, I'll stick to a fairly limited subset > for now. Hopefully once that's cleared, it'll be easier for me to guess > what the rest is about: If you haven't already done so, I'd recommend M-x load-file cc-langs.elc, then typing something like the following into *scratch* and evaluating it after byte-compiling various cc-files.el: (let ((sym (intern "c-identifier-start" c-lang-constants))) (list (symbol-name sym) (symbol-value sym) (symbol-plist sym) ;; (symbol-function sym) )) > - What the relationship between the `source' property and the > `symbol-value' of the symbols that are in the c-lang-constants obarray? The `source' property holds a cons of the source file (as a symbol, e.g. `cc-langs') and the source code of the c-lang-defconst (somewhat processed for uniformity by c-lang-defconst). The symbol-value is an alist of elements which look like, e.g., (c-mode . "[[:alpha:]_]"), there being a separate element for each language. It is generated by byte-compiling cc-mode.el, and contains the final value of the c-lang-defconsts, used in generating the c-lang-defvars (which are ordinary variables in the standard obarray). > - Do those symbols hold other information (I don't see another property > being used, nor does the symbol-function slot seem to be used, but > maybe I just missed it)? The symbol-function is not used (there is no occurrence of "symbol-function" in cc-defs.el). Some other properties stored in the obarray are `variable-documentation' and `dependents', the latter being a list of `c-lang-defconst's which use the current `c-lang-defconst' (the list can contain the current `c-lang-defconst' "recursively"). I don't think there are any more. > - It seems that the `source' property contain an list of (FILE . LANG-ALIST) > entries (where each LANG-ALIST is a list of (MODES . CODE)). Right? Yes. > Here's the main question: > - Why is this FILE needed? Why is it important to preserve ordering > between various FILEs? Why do we sometimes `load' those FILEs (in > c-find-assignment-for-mode)? Which kind of concrete situation is this > supposed to address? I'm not unconfused enough to say. Sorry. But it seems it will have to do with modes derived from CC Mode using c-add-language. I'm trying to work out why we need to load the source files when all the information is already contained in the c-lang-constants obarray. > My vague understanding is that we want to allow c-lang-defconst to be > called (for the same variable) from different files for different > major modes. Of course, for those modes supported natively by CC-mode, > they're all in cc-langs.el ..... There are some c-lang-defconsts in cc-fonts.el. > .... so there's only ever a single FILE there and it never needs to be > (auto)loaded. But even for modes distributed separately [BTW, it'd be > good to try and keep track of them to some extent, which reminds me I > should do the same for SMIE], I don't see why ordering is important (I > mean I understand why ordering is important w.r.t the derivation > hierarchy, but not w.r.t FILEs) nor in which circumstance you'd already > know about the existence of a call to c-lang-defconst in some FILE yet > that FILE isn't loaded yet (i.e. why/when would you know and need to > (auto)load FILE from c-find-assignment-for-mode)? > Stefan -- Alan Mackenzie (Nuremberg, Germany).