From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: How to get plist properties list? Date: Sat, 9 Jan 2021 10:54:17 +0300 Message-ID: References: <7eec4142-3c37-4084-9ea1-73df5df2c821@default> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30018"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.0 (3d08634) (2020-11-07) Cc: help-gnu-emacs@gnu.org To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jan 09 08:56:37 2021 Return-path: Envelope-to: geh-help-gnu-emacs@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 1ky96x-0007fO-Vj for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 09 Jan 2021 08:56:35 +0100 Original-Received: from localhost ([::1]:58324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ky96x-0004VW-0p for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 09 Jan 2021 02:56:35 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39644) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ky96Z-0004VK-Mo for help-gnu-emacs@gnu.org; Sat, 09 Jan 2021 02:56:11 -0500 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:59369) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ky96X-0004sl-Ez for help-gnu-emacs@gnu.org; Sat, 09 Jan 2021 02:56:11 -0500 Original-Received: from localhost ([::ffff:41.210.145.70]) (AUTH: PLAIN securesender, TLS: TLS1.2,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 000000000002DFDC.000000005FF96196.0000653D; Sat, 09 Jan 2021 00:56:05 -0700 Mail-Followup-To: Stefan Monnier , help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:127117 Archived-At: * Stefan Monnier [2021-01-08 09:51]: > > I would like to understand what is the problem. I don't. You tell me > > that `elt' is problem, that is how I understand it. > > > > Could I maybe rather use `nth' to replace `elt'? > > No, same problem. > Think of it this way: consider your list of N elements as a road that's > N kilometers long. `elt` and `nth` are operations which involve walking > from the beginning of the road to the Nth kilometer. So to collect all > the keys found at kilometers 0, 2, 4, ... your loop does: > - walk 0 kilometers and collect the key (then come back). > - walk 2 kilometers from the start and collect the key (then come back). > - walk 4 kilometers from the start and collect the key (then come back). > - walk 6 kilometers from the start and collect the key (then come > back). So far I have seen from similar discussion on `length' on emacs-devel mailing list, people were discussing of its efficiencies and maybe now you also discuss of efficiency. For me as programmer of systems that I need I use `elt' about 200+ times in all programs. `nth' I use less times, maybe 30 times. I do not know what is a big difference between those two. If I wish to get the element like number 17th I do not know what I should do. And I did not read all emails. I also do not feel why it should be wrong, finally it is not really kilometers but computer doing its iteration over elements. The above statement is unclear to me as your distant student. I do understand you speak of efficiency, but practically I yet do not see the problem. For example I cannot practically at this moment find some delays that would bother me. > >> > But maybe there is some more simpler way to get plist properties list? > >> > >> Probably not the simplest but this should work: > >> > >> (defun plist-keys (plist) > >> (let (keys iskey) > >> (dolist (x plist) > >> (if (setq iskey (not iskey)) (push x keys))) > >> (nreverse keys))) > > > > As we already discussed it, `dolist' is not perfect, it would give > > warnings, not logical at all. > > There's no warning for this code, AFAIK, no. > > > In the above example `x' would not give warning, but if there would be > > return value then `x' would be part of warning, while return variable > > would not be. That is not logical to me, so I consider `dolist' not > > well handled by compiler and is better for me not to use it. > > Just never use that 3rd argument and you'll never get that warning. I do understand your point, but I also remember that warning was not about the third argument and that when macro is defined as such then programmers shall use it. In my opinion compiler should not warn when programmer uses function by its description. But when you make something obsolete, then I would say it would be fine. `dolist' seem like Common Lisp so I was expecting it to work as CL. I will see more emails after this one. Jean