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

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

Re: [External] : Re: How to make M-x TAB not work on (interactive) decla


From: Jean Louis
Subject: Re: [External] : Re: How to make M-x TAB not work on (interactive) declaration?
Date: Tue, 17 Jan 2023 20:19:44 +0300
User-agent: Mutt/2.2.9+54 (af2080d) (2022-11-21)

* Nick Dokos <ndokos@gmail.com> [2023-01-17 19:27]:
> The "empty sum" and "empty product" conventions are described in the
> corresponding articles in Wikipedia too - they might help:
> 
>    https://en.wikipedia.org/wiki/Empty_sum
>    https://en.wikipedia.org/wiki/Empty_product

Thanks much.

I understand that "summation" is not equal to "addition" as summation
is the addition of a sequence of any kind of numbers, called addends
or summands; the result is their sum or total:
https://en.wikipedia.org/wiki/Summation

Then back to: https://en.wikipedia.org/wiki/Empty_sum
where it says:

In mathematics, an empty sum, or nullary sum,[1] is a summation where
the number of terms is zero. The natural way to extend non-empty
sums[2] is to let the empty sum be the additive identity. 

Basically function `+' deals with summation, not with addition. But
that is conclusion I can draw alone with help of your references,
without confirmation by docstring, manual or some references.

Though I do not understand why it has to deal with summation, and not
straight with addition? What is use in Lisp?

In this other reference: https://en.wikipedia.org/wiki/Empty_product
the issue with Lisp is mentioned, and we can read, that in many
programming languages it is so, like in Python, Lisp, but in Perl is
not so, then it says:

Multiplication is an infix operator and therefore a binary operator,
complicating the notation of an empty product. Some programming
languages handle this by implementing variadic functions. For example,
the fully parenthesized prefix notation of Lisp languages gives rise
to a natural notation for nullary functions:

(* 2 2 2)   ; evaluates to 8
(* 2 2)     ; evaluates to 4
(* 2)       ; evaluates to 2
(*)         ; evaluates to 1

and:

In mathematics and in computer programming, a variadic function is a
function of indefinite arity, i.e., one which accepts a variable
number of arguments. Support for variadic functions differs widely
among programming languages. 

I may alone assume, while still needing confirmation, that Emacs Lisp,
Common Lisp use those variadic function. Not that I have got stable
feeling with it.

Though that still does not tell me why? 

I have excluded the purpose for `apply' and similar functions as that
is handled properly with PicoLisp where (*) ➜ NIL -- and maybe I am
wrong, but with all references I came closer some reasoning. But all
the reasoning is not confirmed in Lisp books.

What I understand from C is thet if number of args nargs is 0 is that
result shall be 1 -- that alone does not explain why and how is it
useful in Lisp.

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);
}


-- 
Jean

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

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



reply via email to

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