help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [External] : Re: (*) -> 1


From: Drew Adams
Subject: RE: [External] : Re: (*) -> 1
Date: Wed, 18 Jan 2023 18:17:21 +0000

> I see it this way:
> - For this I don't see clearly why we are supposed to imagine 1 when
>   two factors are required for multiplication. I would rather like
>   error for missing argument.

I explained, and showed code, for how you can
do this yourself - create your own `my-times'
function that _requires_ exactly two args.  I
showed it for addition, not multiplication,
but the code is the same.

And I showed you how you could code an Elisp
product function equivalent to Elisp's *,
based only on your `my-times' function (which
requires two args).  Again, I showed it for
addition/summation, not multiplication/product,
but the code is the same.

That latter code was just to show you the
relation between the two - expressed in Elisp.
You don't want/like variable-arity sum/product
functions, for some reason.  You can use your
own, binary ones - you need never use + or *.

I really suggest you take a look at the code
and my explanation.  I think that will help you
understand all that you're so far confused about,
wondering about, asking about, or interested in.

Elisp doesn't bother defining binary functions
for adding and multiplying.  Instead it defines
variable-arity versions (summation and product,
if you prefer those names).

It does so _because those are more general_ - you
can use them with any number of args - including
two.  But if _you_ want binary versions, which
raise an error if other than two args are passed,
you can easily get that, with no cost.  QED.

There's really nothing more to say.  The Elisp
doc is fine here - it's correct, sufficient, and
clear to just say that + and * take "any number
of arguments".

And readers should understand that "any number
of args" for an Elisp function includes _zero_
args.  Why?  Because Elisp allows for nullary
functions: it allows functions to take zero args.

You seemed to think I was practical-joking when
pointing out that the doc includes the zero-args
case when it says "any number", _because_ zero
can be the _number_ of args:

> > A zero number of args means zero args,
> > which means no args.
>
> Aha that is what you mean. Sounds like
> practical joke with function descriptions.

Nope; not a joke.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]