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

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

Re: (*) -> 1


From: Óscar Fuentes
Subject: Re: (*) -> 1
Date: Wed, 18 Jan 2023 14:57:01 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Jean Louis <bugs@gnu.support> writes:

> * Michael Heerdegen <michael_heerdegen@web.de> [2023-01-17 22:20]:
>> The question of use is a valid one, we missed to answer it yet.  It
>> wasn't clear to me that this was part of what you are asking for.
>
> Yes, that one. 
>
> Why authors decided to have (*) ➜ 1 which in case of me who could
> delete some argument like from (* tonnes quantity) I could by mistake
> delete "tonnes and quantity" and result of (*) would not be detected
> because there is no error

Throwing an error on this case is a reasonable possibility for the
language designers, but instead they decided to extend * to zero and one
arguments. Why? because it is convenient, because it makes possible to
do things like (apply '* some-list) without caring about how many
elements some-list has, which is handy when some-list comes from a place
you don't control. As far as the extension of * is reasonable, it is
nice to have, that's what the language designers thought.

So what's the reasonable extension of * (the variadic function!) to zero
arguments? Let's use some basic algebra:

(apply '* (list a b)) == (apply '* (list 1 1 a b))

which is the same as:

a * b == 1 * 1 * a * b

remove b:

a == 1 * 1 * a

remove a:

? == 1 * 1

which the same as:

(apply '* ()) == (apply '* (1 1))

or

(*) == (* 1 1)

So * applied to zero arguments shall be 1, because any other value would
break the equality.




reply via email to

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