From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: as for Calc and the math library Date: Sun, 11 Aug 2024 21:52:24 +0300 Message-ID: <868qx2j3iv.fsf@gnu.org> References: <87bk20yoya.fsf@dataswamp.org> <86zfpjirkg.fsf@gnu.org> <877ccnj9dp.fsf@localhost> <86bk1zhrf5.fsf@gnu.org> <874j7qkj97.fsf@localhost> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14638"; mail-complaints-to="usenet@ciao.gmane.io" Cc: incal@dataswamp.org, emacs-devel@gnu.org To: Ihor Radchenko Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Aug 11 20:53:16 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 1sdDgo-0003f5-Bh for ged-emacs-devel@m.gmane-mx.org; Sun, 11 Aug 2024 20:53:14 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sdDg8-0001ZL-6t; Sun, 11 Aug 2024 14:52:32 -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 1sdDg6-0001Z8-5b for emacs-devel@gnu.org; Sun, 11 Aug 2024 14:52:30 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sdDg4-0000bO-S6; Sun, 11 Aug 2024 14:52:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=sT+0UYZYPMhXx19cCqnC9gvHYgfZmnPmdszIw0U6roU=; b=BCm5tRhTjA8t HupkZxTb/fLtQ3Guew1Np+3AN4wAC+IBFmJifTcD5odgCqODhVKCGSjJUA0gASCtNB3JBCsCSM/hW 7GmXLtZzC+G5xAwU6ELDFEkIratea+4oUNwqHsPxrEkfno1kRbibIosycZJfi5/a1aJqHzaL1oUfW 6OOEIzB5vOKd+8D4N/xM8TRPOyxgrLfMuP+e7QL6i4/lvxW8bR+69cDgeyW1Z6AJTXnqpdQ5c3dhZ 2/b3I0toN+xcQmKSzrhO6fWoaToZLZIuciFn5wFwuIrFvUDv1Z8miE6aCDWdHy/Jq6XW7w7fo/tzE KwcxyrI3mFKPGeIylAbm0g==; In-Reply-To: <874j7qkj97.fsf@localhost> (message from Ihor Radchenko on Sun, 11 Aug 2024 18:27:16 +0000) 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:322648 Archived-At: > From: Ihor Radchenko > Cc: incal@dataswamp.org, emacs-devel@gnu.org > Date: Sun, 11 Aug 2024 18:27:16 +0000 > > Eli Zaretskii writes: > > >> 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. (1) is documentation of Calc data structures. If you mean the large commentary that describes the various form of objects that Calc can handle, then what is left to document? > 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. Doesn't (a) already exist in the Calc manual chapter "Data Types"? And if not, then you are talking about enhancing the documentation of Calc, which is always welcome, but I fail to see how it is a step towards a separate library. > 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. And how is this relevant to (2), which is about refactoring some of Calc code into hopefully easier-to-use functions? > For example, take `math-add' - no > docstring, and go try adding invalid arguments: > > M-: (math-add "foo" '(frac 1 2)) It's a small wonder that you cannot math-add a string, especially since none of the objects described in the commentary are any kind of string. More generally, AFAIU these don't have doc strings because they are internal functions. But still, I don't understand the relevance. > 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)) You again play against the rules: 0.1 is not a valid object for these functions. Try M-: (math-add '(float 1 -1) '(frac 1 10))