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.devel Subject: Re: lengths and stuff Date: Mon, 28 Dec 2020 10:15:11 +0300 Message-ID: References: <875z4ob5c9.fsf@gnus.org> <83mtxzly4f.fsf@gnu.org> <87czyvsv3h.fsf_-_@db48x.net> <87v9cnqgjr.fsf@logand.com> <40d9718a-adcc-4ac8-a7dd-8b66270f40d3@default> <87sg7rq8dn.fsf@logand.com> 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="3362"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.0 (3d08634) (2020-11-07) Cc: Drew Adams , emacs-devel@gnu.org To: Tomas Hlavaty Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Dec 28 08:19:44 2020 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 1ktmoi-0000nB-Fj for ged-emacs-devel@m.gmane-mx.org; Mon, 28 Dec 2020 08:19:44 +0100 Original-Received: from localhost ([::1]:40682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ktmoh-0007at-Gl for ged-emacs-devel@m.gmane-mx.org; Mon, 28 Dec 2020 02:19:43 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ktmo5-0007AD-A6 for emacs-devel@gnu.org; Mon, 28 Dec 2020 02:19:05 -0500 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:39355) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ktmo1-0004S2-Qy for emacs-devel@gnu.org; Mon, 28 Dec 2020 02:19:05 -0500 Original-Received: from localhost ([::ffff:154.225.255.210]) (AUTH: PLAIN securesender, TLS: TLS1.2,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 000000000005DD3D.000000005FE986E1.00004B41; Mon, 28 Dec 2020 00:18:57 -0700 Mail-Followup-To: Tomas Hlavaty , Drew Adams , emacs-devel@gnu.org Content-Disposition: inline In-Reply-To: <87sg7rq8dn.fsf@logand.com> 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: 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:261983 Archived-At: * Tomas Hlavaty [2020-12-27 23:53]: > On Sun 27 Dec 2020 at 10:52, Drew Adams wrote: > >> Using length in a predicate is yet completely different and most > >> likely bad because to answer the predicate, traversing the whole list > >> is wasted time and energy. > > > > (lambda (xs) (= (length xs) 25)) ; need to count elts > > Is that a joke? > > The predicates were proposed to help programers avoid writing such bad > code. And if somebody writes such bad code, it is almost trivial to fix > it with search and replace: > > "(= (length" -> "(length=" > "(< (length" -> "(length<" > "(> (length" -> "(length>" > "(/= (length" -> "(length/=" > "(<= (length" -> "(length<=" > "(>= (length" -> "(length>=" > > Also the "symmetry" (or exhaustiveness?) here is to assist in easily > fixing bad code with minimum changes. > > Nothing of course helps to those who are determined to unneccessarily > count _all_ the elements of lists. May I understand if that proposal is to implement it in C or in Lisp? Does that mean when (length< list-1 10) is implemented in C it would become faster than: (< (length list-1) 10) ? Or is that proposal to make Lisp functions like: (defun length< (list n) (when (< (length list) n) t))