unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: incal@dataswamp.org, emacs-devel@gnu.org
Subject: Re: as for Calc and the math library
Date: Sun, 11 Aug 2024 18:27:16 +0000	[thread overview]
Message-ID: <874j7qkj97.fsf@localhost> (raw)
In-Reply-To: <86bk1zhrf5.fsf@gnu.org>

Eli Zaretskii <eliz@gnu.org> 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 <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>



  parent reply	other threads:[~2024-08-11 18:27 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-10 22:48 as for Calc and the math library Emanuel Berg
2024-08-11  4:58 ` Eli Zaretskii
2024-08-11 16:45   ` Ihor Radchenko
2024-08-11 16:55     ` Christopher Dimech
2024-08-11 17:05     ` Emanuel Berg
2024-08-11 17:59     ` Eli Zaretskii
2024-08-11 18:17       ` Christopher Dimech
2024-08-11 18:32         ` Eli Zaretskii
2024-08-11 19:53           ` Christopher Dimech
2024-08-11 18:27       ` Ihor Radchenko [this message]
2024-08-11 18:38         ` Emanuel Berg
2024-08-12  6:28           ` New Emacs features via Google Summer of Code (or other similar stipend schemes) (was: as for Calc and the math library) Ihor Radchenko
2024-08-12 11:09             ` Eli Zaretskii
2024-08-12 12:10               ` New Emacs features via Google Summer of Code (or other similar stipend schemes) Joel Reicher
2024-08-12 18:59                 ` Ihor Radchenko
2024-08-12 22:28                   ` Pedro
2024-08-14 10:07                     ` Ihor Radchenko
2024-08-15 11:44                     ` Ihor Radchenko
2024-08-12 19:17               ` New Emacs features via Google Summer of Code (or other similar stipend schemes) (was: as for Calc and the math library) Ihor Radchenko
2024-08-13  8:12                 ` New Emacs features via Google Summer of Code (or other similar stipend schemes) Andrea Corallo
2024-08-18 11:48                   ` Ihor Radchenko
2024-08-18 12:35                     ` Eli Zaretskii
2024-08-18 12:52                       ` Ihor Radchenko
2024-08-18 13:39                         ` Eli Zaretskii
2024-08-18 13:56                           ` RTF import/export emacs (was: New Emacs features via Google Summer of Code (or other similar stipend schemes)) Ihor Radchenko
2024-08-18 14:14                             ` Eli Zaretskii
2024-08-18 14:35                               ` Ihor Radchenko
2024-08-18 14:38                                 ` Eli Zaretskii
2024-08-18 17:37                                 ` Jim Porter
2024-08-18 18:16                                   ` Eli Zaretskii
2024-08-18 18:38                                     ` Jim Porter
2024-08-18 19:05                                       ` tomas
2024-08-13 11:02                 ` New Emacs features via Google Summer of Code (or other similar stipend schemes) (was: as for Calc and the math library) Eli Zaretskii
2024-08-18 11:09                   ` Ihor Radchenko
2024-08-18 11:25                     ` Eli Zaretskii
2024-08-18 11:33                     ` Stefan Kangas
2024-08-18 12:47                       ` Ihor Radchenko
2024-08-11 18:52         ` as for Calc and the math library Eli Zaretskii
2024-08-11 19:13           ` Ihor Radchenko
2024-08-12  2:24             ` Eli Zaretskii
2024-08-11 21:50           ` Christopher Dimech
  -- strict thread matches above, loose matches on Subject: below --
2024-08-12  5:30 arthur miller
2024-08-12 11:00 ` Eli Zaretskii
2024-08-12 11:23   ` Nicolas Martyanoff
2024-08-12 11:46     ` Eli Zaretskii
2024-08-12 12:11       ` Nicolas Martyanoff
2024-08-12 13:22         ` Eli Zaretskii
2024-08-12 13:38           ` Christopher Dimech
2024-08-15  1:59             ` Richard Stallman
2024-08-15  3:06               ` Christopher Dimech
2024-08-15  6:43                 ` Eli Zaretskii
2024-08-15 13:28                   ` Christopher Dimech
2024-08-15 16:39                     ` Eli Zaretskii
2024-08-13  7:16           ` Sv: " arthur miller
2024-08-13 12:12             ` Eli Zaretskii
2024-08-13 13:10               ` Nicolas Martyanoff
2024-08-13 13:30                 ` Eli Zaretskii
2024-08-13 13:48                   ` Nicolas Martyanoff
2024-08-13 21:43               ` Sv: " arthur miller
2024-08-14  5:09                 ` Eli Zaretskii
2024-08-14  8:45                   ` Sv: " arthur miller
2024-08-14  9:56                     ` Nicolas Martyanoff
2024-08-14 10:43                       ` Eli Zaretskii
2024-08-13  5:39       ` Gerd Möllmann
2024-08-14  4:11         ` Gerd Möllmann
2024-08-14  6:23           ` Eli Zaretskii
2024-08-14  6:28             ` Gerd Möllmann
2024-08-14  6:43               ` Eli Zaretskii
2024-08-14 14:00             ` Suhail Singh
2024-08-14 14:20               ` Eli Zaretskii
2024-08-14 15:08                 ` Suhail Singh
2024-08-14 15:31                   ` Eli Zaretskii
2024-08-14 16:00                     ` Suhail Singh
2024-08-14 16:24                       ` Eli Zaretskii
2024-08-14 20:35                       ` Emanuel Berg
2024-08-15  5:00                     ` Sv: " arthur miller
2024-08-15  7:02                       ` Eli Zaretskii
2024-08-15 20:09                         ` Sv: " arthur miller
2024-08-16  5:47                           ` Eli Zaretskii
2024-08-18 16:38                           ` Richard Stallman
2024-08-18 17:27                             ` Christopher Dimech
2024-08-19 12:05                             ` Sv: " arthur miller
2024-08-24  2:59                               ` Richard Stallman
2024-08-24  2:59                               ` Richard Stallman
2024-08-14 14:35               ` Gerd Möllmann
2024-08-14 14:40                 ` Nicolas Martyanoff
2024-08-14 14:47                   ` Gerd Möllmann
2024-08-14 14:49                   ` Eli Zaretskii
2024-08-14  5:29     ` Madhu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874j7qkj97.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=incal@dataswamp.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).