From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.devel Subject: Re: as for Calc and the math library Date: Sun, 11 Aug 2024 18:27:16 +0000 Message-ID: <874j7qkj97.fsf@localhost> References: <87bk20yoya.fsf@dataswamp.org> <86zfpjirkg.fsf@gnu.org> <877ccnj9dp.fsf@localhost> <86bk1zhrf5.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40437"; mail-complaints-to="usenet@ciao.gmane.io" Cc: incal@dataswamp.org, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Aug 11 20:26:47 2024 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 1sdDHD-000AJK-Gc for ged-emacs-devel@m.gmane-mx.org; Sun, 11 Aug 2024 20:26:47 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sdDGi-0005et-D6; Sun, 11 Aug 2024 14:26:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sdDGh-0005eF-3I for emacs-devel@gnu.org; Sun, 11 Aug 2024 14:26:15 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sdDGb-0005oZ-U2 for emacs-devel@gnu.org; Sun, 11 Aug 2024 14:26:14 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id AE38A240101 for ; Sun, 11 Aug 2024 20:26:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1723400766; bh=ie8ijL9DDFx8nf6cZKDtQXnUgE0LOYIqFby/q9M/Jxc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=X2S/tR3uhjRBHpCtRQsADmhvbxcY+fLbrEpqaYnvb5wx1NCquDwZsx3w7waks25Ju yF9A1+JsWmcAy9f7lrVgNRheCpJaKAG+C/hcu7TL/ZyJS1KVWgDjzLh3lkPtAhlOH9 hpuYlqVyTJyJvkALNFgpfx3Z/d7IUQ5dNbnLW/2oovfldaed0fS6OqViISiLm39vgZ 7hs9lKuR6ZW5bXMAyFrxcC5xj9H+6qtKf6iGHBkAPYqs5zpLuveEKi/A7FIWX0R1uv L26T5Ykmk5KSl7nXoRCCudQl4qTtsCgtbk6DJH83LmilhEaOS0K9CxGJ4fBMdMwHpU vqQEtH3bxJrFg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4WhmLP6R1Rz6tsB; Sun, 11 Aug 2024 20:26:05 +0200 (CEST) In-Reply-To: <86bk1zhrf5.fsf@gnu.org> Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:322646 Archived-At: Eli Zaretskii writes: >> > If Emacs is to have a math library, the library must use high-quality >> > mathematical and numerical algorithms that are well-known and >> > described in many textbooks on this subject matter... >> >> I agree with this point, but I suspect that writing such a library from >> scratch might be a bit difficult. > > It depends on the scope and the person who'd like to work on that. Yes, of course. If somebody is up to writing a serious math lib, it would be better. But having a bit simpler task idea can increase the pool of potential volunteers. >> May I suggest an alternative: abstract out GNU Calc math routines to be >> available from Elisp without having to read Calc sources. >> Such a task would require: >> 1. Documenting some Calc data structures >> 2. Possibly refactoring some Calc functions to use simpler API. >> >> It would be a much easier task and can improve the existing >> functionality. > > I don't think I understand well enough what will this entail in > practice. Can you show an example of doing this for a couple of > functions? For (1), I was referring to ";;;; Arithmetic routines." in calc.el. Now, people must simply know the internal format of special number representations to work with Calc from Elisp. It might be worth (a) putting them into a proper manual (some kind of Calc Lisp API description); (b) maybe creating constructor functions to abstract the types away. For (2), for starters, Calc functions often do not even have docstrings. One simply has to guess(?) or read the code to understand what kinds of values can be passed. For example, take `math-add' - no docstring, and go try adding invalid arguments: M-: (math-add "foo" '(frac 1 2)) Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p "foo") (math-mul "foo" 2) (calc-add-fractions "foo" (frac 1 2)) (math-add "foo" (frac 1 2)) The error checking could be improved, especially since it is a polymorphic function that is capable of doing things like (math-add '(vec (frac 1 2) 3 1) '(frac 1 2)) ; => (vec 1 (frac 7 2) (frac 3 2)) but somehow not M-: (math-add 0.1 '(frac 1 10)) Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p 2.0) (math-gcd 2.0 10) (math-make-frac 2.0 10) (calc-add-fractions 0.1 (frac 1 10)) (math-add 0.1 (frac 1 10)) > In any case, this job, as any other job in Emacs, needs its > volunteer(s). Until we have such volunteers, it's all academic. Yes, of course. I was hoping that Emanual (who is apparently interested in this topic, or at least in improving Elisp) can be the one. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at