diff options
| author | Philipp Stephani | 2019-04-24 13:54:54 +0200 |
|---|---|---|
| committer | Philipp Stephani | 2019-04-24 13:54:54 +0200 |
| commit | b6d8d34aede02a6af7a614f32b86292ee4ba1757 (patch) | |
| tree | c6cdbf818eb3c749a1937e1e198fd564fb5de630 | |
| parent | c4bacb1215bfdf058b374312256c27eaea1304a4 (diff) | |
| download | emacs-b6d8d34aede02a6af7a614f32b86292ee4ba1757.tar.gz emacs-b6d8d34aede02a6af7a614f32b86292ee4ba1757.zip | |
* doc/lispref/internals.texi (Module Values): Add a GMP example
| -rw-r--r-- | doc/lispref/internals.texi | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/doc/lispref/internals.texi b/doc/lispref/internals.texi index 3e6488a5ccf..5ae71afbef2 100644 --- a/doc/lispref/internals.texi +++ b/doc/lispref/internals.texi | |||
| @@ -1543,6 +1543,31 @@ integral object. After you have finished using | |||
| 1543 | or similar. | 1543 | or similar. |
| 1544 | @end deftypefn | 1544 | @end deftypefn |
| 1545 | 1545 | ||
| 1546 | The following example uses GMP to calculate the next probable prime | ||
| 1547 | after a given integer: | ||
| 1548 | |||
| 1549 | @example | ||
| 1550 | #include <assert.h> | ||
| 1551 | #include <gmp.h> | ||
| 1552 | |||
| 1553 | #define EMACS_MODULE_GMP | ||
| 1554 | #include <emacs-module.h> | ||
| 1555 | |||
| 1556 | static emacs_value | ||
| 1557 | next_prime (emacs_env *env, ptrdiff_t nargs, emacs_value *args, | ||
| 1558 | void *data) | ||
| 1559 | @{ | ||
| 1560 | assert (nargs == 1); | ||
| 1561 | emacs_mpz p; | ||
| 1562 | mpz_init (p.value); | ||
| 1563 | env->extract_big_integer (env, args[0], &p); | ||
| 1564 | mpz_nextprime (p.value, p.value); | ||
| 1565 | emacs_value result = env->make_big_integer (env, &p); | ||
| 1566 | mpz_clear (p.value); | ||
| 1567 | return result; | ||
| 1568 | @} | ||
| 1569 | @end example | ||
| 1570 | |||
| 1546 | The @acronym{API} does not provide functions to manipulate Lisp data | 1571 | The @acronym{API} does not provide functions to manipulate Lisp data |
| 1547 | structures, for example, create lists with @code{cons} and @code{list} | 1572 | structures, for example, create lists with @code{cons} and @code{list} |
| 1548 | (@pxref{Building Lists}), extract list members with @code{car} and | 1573 | (@pxref{Building Lists}), extract list members with @code{car} and |