unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Drew Adams <drew.adams@oracle.com>
Cc: "tomas@tuxteam.de" <tomas@tuxteam.de>,
	"help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>,
	Paul Eggert <eggert@cs.ucla.edu>
Subject: Re: (*) -> 1
Date: Thu, 19 Jan 2023 12:05:32 +0300	[thread overview]
Message-ID: <Y8kH3AbCAHOFXwq3@protected.localdomain> (raw)
In-Reply-To: <SJ0PR10MB5488A23773107476AD48855AF3C79@SJ0PR10MB5488.namprd10.prod.outlook.com>

Hello Paul,

I suppose you made (*) ➜ 1 function as such, please see and let me
know if you know the reason why you added it.

Too much was told about it on mailing list, but I can't find
reasons. People tried to explain it with mathematics.

Was the reason mathematical set theory? What was reason for your
change in the `*' function back in 2018?

* Drew Adams <drew.adams@oracle.com> [2023-01-18 23:37]:
> See the code I provided.  Passing a list of values
> to a unary `foo':
> 
> (foo '(3 6 9))
> (foo '(2))
> (foo ())
> 
> Passing multiple values to a variable-arity `foo':
> 
> (foo 3 6 9)
> (foo 2)
> (foo)

I understand that idea and understood in first time. 

Only that it does not fit in general context of any function. 

And explanation tries to fit it for every function.

> > Without practical use I can only tell it is capricious decision.
> 
> Without using it or understanding it you can
> continue to think so, I suppose.

And how can I understand if none of participants demonstrated the use?

Not mentioning justifications how somewhere outside of Lisp something
exists theoretically... that outside is not Emacs Lisp.

> > Maybe we can tell it this way:
> > If there is any Emacs Lisp program which does not use (*) or (* a)
> > anywhere but which would raise error if we re-define function
> > to require 2 arguments -- then there must be some use of it.
> 
> How about + or * with more than 2 args?  Do you
> think allowing that is also useless imagination,
> a capricious decision, madness imposed by useless
> mathematicians?

My question was simple. You counter with questions. Deviation from
straight answer does not make it an answer.

If there is any Emacs Lisp program which does not use (*) or (* a)
anywhere but which would raise error if we re-define function
to require 2 arguments?

It is not a mind boggling question, it is practical question to
understand if there is use of it.

What is mind boggling is that people explain how it must be so,
without showing use for it.

I can make my private functions as I want, I can return funny stuff
like "Doomed", and I can justify it that I don't like raising errors,
or that I have seen game which gave me the idea to return that result.

I believe there is plausible explanation which was not mentioned in
the mailing list, as somebody must have the answer for it.

Trying to explain it by using mathematics outside of Emacs without
showing me use of it does not give me understanding.

I am trying to search to root of it, and I find that function is
defined as this:

DEFUN ("*", Ftimes, Stimes, 0, MANY, 0,
       doc: /* Return product of any number of arguments, which are numbers or markers.
usage: (* &rest NUMBERS-OR-MARKERS)  */)
  (ptrdiff_t nargs, Lisp_Object *args)
{
  if (nargs == 0)
    return make_fixnum (1);
  Lisp_Object a = check_number_coerce_marker (args[0]);
  return nargs == 1 ? a : arith_driver (Amult, nargs, args, a);
}

but back in time it was defined as following:
https://github.com/emacs-mirror/emacs/blob/8f3a2c2659ddee1ae84b4b8bb28f6c388f87fd0f/src/data.c

DEFUN ("*", Ftimes, Stimes, 0, MANY, 0,
       doc: /* Return product of any number of arguments, which are numbers or markers.
usage: (* &rest NUMBERS-OR-MARKERS)  */)
  (ptrdiff_t nargs, Lisp_Object *args)
{
  return arith_driver (Amult, nargs, args);
}

and that was in August 5, 2013, and then by searching commmits, I can
find:

August 28, 2018, it was not there!!!

Does that mean all of explanations by participants were not valid
before that date? 

Then I look at the first time it appeared in Emacs:
https://github.com/emacs-mirror/emacs/blob/fe042e9d15da7863b5beb4c2cc326a62d2c7fccb/src/data.c

Improve arithmetic performance by avoiding bignums until needed.
Also, simplify bignum memory management, fixing some unlikely leaks.
This patch improved the performance of (+ 2 2) by a factor of ten
on a simple microbenchmark computing (+ x 2), byte-compiled,
with x a local variable initialized to 2 via means the byte
compiler could not predict: performance improved from 135 to 13 ns.
The platform was Fedora 28 x86-64, AMD Phenom II X4 910e.
Performance also improved 0.6% on ‘make compile-always’.
* src/bignum.c (init_bignum_once): New function.
* src/emacs.c (main): Use it.
* src/bignum.c (mpz): New global var.
(make_integer_mpz): Rename from make_integer.  All uses changed.
* src/bignum.c (double_to_bignum, make_bignum_bits)
(make_bignum, make_bigint, make_biguint, make_integer_mpz):
* src/data.c (bignum_arith_driver, Frem, Flogcount, Fash)
(expt_integer, Fadd1, Fsub1, Flognot):
* src/floatfns.c (Fabs, rounding_driver, rounddiv_q):
* src/fns.c (Fnthcdr):
Use mpz rather than mpz_initting and mpz_clearing private
temporaries.
* src/bignum.h (bignum_integer): New function.
* src/data.c (Frem, Fmod, Fash, expt_integer):
* src/floatfns.c (rounding_driver):
Use it to simplify code.
* src/data.c (FIXNUMS_FIT_IN_LONG, free_mpz_value):
Remove.  All uses removed.
(floating_point_op): New function.
(floatop_arith_driver): New function, with much of the guts
of the old float_arith_driver.
(float_arith_driver): Use it.
(floatop_arith_driver, arith_driver):
Simplify by assuming NARGS is at least 2.
All callers changed.
(float_arith_driver):
New arg, containing the partly converted value of the next arg.
Reorder args for consistency.  All uses changed.
(bignum_arith_driver): New function.
(arith_driver): Use it.  Do fixnum-only integer calculations
in intmax_t instead of mpz_t, when they fit.
Break out mpz_t calculations into bignum_arith_driver.
(Fquo): Use floatop_arith_driver instead of float_arith_driver,
since the op is known to be valid.
(Flogcount, Fash): Simplify by coalescing bignum and fixnum code.
(Fadd1, Fsub1): Simplify by using make_int.


As I cannot decipher above, does that mean that (*) ➜ 1 was added only
for reason to speed up some C functions in Emacs?

Is that the reason Paul?


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



  reply	other threads:[~2023-01-19  9:05 UTC|newest]

Thread overview: 149+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-07 20:53 How to make M-x TAB not work on (interactive) declaration? Jean Louis
2023-01-07 21:11 ` Ruijie Yu via Users list for the GNU Emacs text editor
2023-01-07 23:40   ` Jean Louis
2023-01-08  6:06 ` Eli Zaretskii
2023-01-08  6:19   ` Emanuel Berg
2023-01-09  4:49     ` Jean Louis
2023-01-09  6:26       ` algorithmic Lisp language (was: Re: How to make M-x TAB not work on (interactive) declaration?) Emanuel Berg
2023-01-09 19:30         ` Jean Louis
2023-01-09 19:32         ` Jean Louis
2023-01-08  6:21   ` How to make M-x TAB not work on (interactive) declaration? Jean Louis
2023-01-08  6:32     ` Emanuel Berg
2023-01-08 10:38     ` Eli Zaretskii
2023-01-08  8:34 ` Tassilo Horn
2023-01-08 11:01   ` Eli Zaretskii
2023-01-09 13:29     ` Tassilo Horn
2023-01-08 21:35   ` Jean Louis
2023-01-08 22:35     ` [External] : " Drew Adams
2023-01-09  0:24       ` Emanuel Berg
2023-01-09 19:47         ` Jean Louis
2023-01-10 23:28           ` Emanuel Berg
2023-01-13  6:21             ` (*)->1 Jean Louis
2023-01-14 12:03               ` (*)->1 Michael Heerdegen
2023-01-14 12:33                 ` (*)->1 Michael Heerdegen
2023-01-15 20:18           ` [External] : Re: How to make M-x TAB not work on (interactive) declaration? Rudolf Adamkovič
2023-01-15 20:57             ` Jean Louis
2023-01-15 22:33               ` Drew Adams
2023-01-15 23:10                 ` Emanuel Berg
2023-01-16 15:28                 ` Jean Louis
2023-01-16 17:07                   ` Drew Adams
2023-01-16 18:25                     ` Jean Louis
2023-01-17  2:20                       ` Drew Adams
2023-01-17  5:28                         ` tomas
2023-01-17 22:20                           ` Drew Adams
2023-01-18  5:14                             ` tomas
2023-01-18  5:26                               ` Emanuel Berg
2023-01-19 11:38                                 ` tomas
2023-01-19 11:51                                   ` Emanuel Berg
2023-01-21 14:05                                     ` tomas
2023-01-23 10:14                                       ` Robert Pluim
2023-01-23 16:44                                       ` Michael Heerdegen
2023-01-23 19:28                                         ` tomas
2023-01-18 17:27                               ` Drew Adams
2023-01-18 17:32                                 ` tomas
2023-01-18 14:32                             ` Jean Louis
2023-01-18 20:36                               ` Drew Adams
2023-01-19  9:05                                 ` Jean Louis [this message]
2023-01-19  9:41                                   ` (*) -> 1 Yuri Khan
2023-01-19 12:52                                   ` Anders Munch
2023-01-17  5:35                         ` [External] : Re: How to make M-x TAB not work on (interactive) declaration? Jean Louis
2023-01-17 15:59                           ` Yuri Khan
2023-01-17 16:42                             ` Jean Louis
2023-01-17 16:05                           ` Michael Heerdegen
2023-01-17 16:17                             ` Yuri Khan
2023-01-17 16:25                             ` tomas
2023-01-17 16:55                             ` (*) -> 1 Jean Louis
2023-01-17 17:52                               ` Michael Heerdegen
2023-01-17 18:11                                 ` Óscar Fuentes
2023-01-17 18:40                                   ` Jean Louis
2023-01-17 19:04                                     ` Óscar Fuentes
2023-01-18 13:15                                       ` Jean Louis
2023-01-18 14:37                                         ` Óscar Fuentes
2023-01-18 18:17                                         ` [External] : " Drew Adams
2023-01-17 19:35                                     ` Michael Heerdegen
2023-01-17 21:12                                   ` Michael Heerdegen
2023-01-17 22:01                                     ` Óscar Fuentes
2023-01-17 23:38                                       ` Michael Heerdegen
2023-01-18  7:50                                         ` Óscar Fuentes
2023-01-18  8:37                                           ` tomas
2023-01-18 12:46                                             ` Óscar Fuentes
2023-01-18 13:44                                               ` Michael Heerdegen
2023-01-18 14:07                                                 ` Óscar Fuentes
2023-01-18 16:19                                                   ` Andreas Eder
2023-01-18 17:14                                                     ` Óscar Fuentes
2023-01-17 18:18                                 ` Jean Louis
2023-01-17 11:52                         ` [External] : Re: How to make M-x TAB not work on (interactive) declaration? Michael Heerdegen
2023-01-15 21:08             ` Jean Louis
2023-01-16  5:02               ` Emanuel Berg
2023-01-16  5:38               ` tomas
2023-01-16 10:10                 ` Jean Louis
2023-01-16 10:41                   ` Yuri Khan
2023-01-16 15:26                     ` Jean Louis
2023-01-17  4:06                 ` Emanuel Berg
2023-01-17 14:00                   ` tomas
2023-01-17 22:43                     ` Emanuel Berg
2023-01-17 16:25                 ` Nick Dokos
2023-01-17 17:19                   ` Jean Louis
2023-02-11  4:38                     ` Ruijie Yu via Users list for the GNU Emacs text editor
2023-02-11 10:54                       ` Jean Louis
2023-01-17 17:41                   ` Nick Dokos
2023-01-16  7:55               ` Yuri Khan
2023-01-16 10:16                 ` Jean Louis
2023-01-16 10:37                   ` Yuri Khan
2023-01-16 15:35                     ` Jean Louis
2023-01-16 15:59                       ` Yuri Khan
2023-01-16 16:14                         ` Jean Louis
2023-01-16 16:47                           ` tomas
2023-01-16 17:07                           ` Drew Adams
2023-01-16 18:41                             ` Jean Louis
2023-01-16 10:51                   ` Anders Munch
2023-01-16 15:38                     ` Jean Louis
2023-01-16 17:40                       ` Andreas Eder
2023-01-16 18:17                         ` tomas
2023-01-16 18:55                           ` Jean Louis
2023-01-16 19:14                             ` tomas
2023-01-16 18:46                         ` Jean Louis
2023-01-17  2:37                           ` Eduardo Ochs
2023-01-17  5:46                             ` (*) -> 1 Jean Louis
2023-01-17 15:56                               ` Michael Heerdegen
2023-01-17 16:29                                 ` Jean Louis
2023-01-17 16:43                                   ` tomas
2023-01-17 17:25                                     ` Jean Louis
2023-01-17 19:11                                       ` Nick Dokos
2023-01-17 17:17                                   ` Michael Heerdegen
2023-01-17 17:26                                     ` Jean Louis
2023-01-17 18:46                                       ` Michael Heerdegen
2023-01-17 18:51                                         ` Jean Louis
2023-01-17 18:04                                     ` Jean Louis
2023-01-17 18:28                                       ` Eduardo Ochs
2023-01-17 19:18                                       ` Michael Heerdegen
2023-01-18 12:27                                         ` Jean Louis
2023-01-18 13:37                                           ` Michael Heerdegen
2023-01-19  8:20                                             ` Jean Louis
2023-01-19 10:06                                               ` Tassilo Horn
2023-01-19 13:43                                               ` Michael Heerdegen
2023-01-19 14:42                                                 ` Jean Louis
2023-01-19 15:27                                                   ` tomas
2023-01-18 13:57                                           ` Óscar Fuentes
2023-01-19  8:32                                             ` Jean Louis
2023-01-19 16:51                                               ` Óscar Fuentes
2023-01-20  8:01                                                 ` Jean Louis
2023-01-18 14:25                                           ` Michael Heerdegen
2023-01-19  8:34                                             ` Jean Louis
2023-01-19 13:54                                               ` Michael Heerdegen
2023-01-19 14:54                                                 ` Jean Louis
2023-01-19 15:19                                                   ` Tassilo Horn
2023-01-19 15:46                                                   ` Michael Heerdegen
2023-01-19 17:38                                                   ` Dr Rainer Woitok
2023-01-20  7:31                                                     ` Jean Louis
2023-01-20 11:49                                                       ` Dr Rainer Woitok
2023-01-19 17:44                                                 ` [External] : " Drew Adams
2023-01-19 21:29                                                   ` Michael Heerdegen
2023-01-20  7:40                                                     ` Jean Louis
2023-01-20  8:47                                                       ` Emanuel Berg
2023-01-18  9:02                                 ` Anders Munch
2023-01-18 10:49                                   ` Michael Heerdegen
2023-01-18 11:10                                     ` Emanuel Berg
2023-01-18 12:48                                   ` Eli Zaretskii
2023-01-18 14:29                                     ` Michael Heerdegen
     [not found]                           ` <87k01lica7.fsf@eder.anydns.info>
2023-01-17 16:04                             ` Jean Louis

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=Y8kH3AbCAHOFXwq3@protected.localdomain \
    --to=bugs@gnu.support \
    --cc=drew.adams@oracle.com \
    --cc=eggert@cs.ucla.edu \
    --cc=help-gnu-emacs@gnu.org \
    --cc=tomas@tuxteam.de \
    /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.
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).