From: Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: help-gnu-emacs@gnu.org
Cc: emacs-devel@gnu.org
Subject: Re: urandom number in Emacs
Date: Sun, 07 Nov 2021 10:28:34 +0100 [thread overview]
Message-ID: <874k8omi0t.fsf@zoho.eu> (raw)
In-Reply-To: 87czncs5f1.fsf@omarpolo.com
Omar Polo wrote:
> Recompiling Emacs from sources takes a couple of minutes,
> and it's a trivial function that you can write and test
> apart before including it to Emacs.
This is much better than recompiling Emacs. Why would you do
that? That's the idea with dynamic modules, then you can have
libraries in C as well as you now have them in .elc files and
use `require' one them and you compile them and only them.
> Also, I'm pretty sure that no distribution ships
> *by default* Emacs modules.
What do you mean?
> Furthermore, it's an annoyance for the users: if I want to
> use it, I have to compile it anyway, whether if it's an
> emacs built-in all I have to do is install/update Emacs via
> my package manager and I'm happy ;-)
Hm ... what Emacs do you run?
You typically get very old versions that way ... Emacs 27
seems to be in the Debian 11 repos ...
This works with Emacs 29 I think ... not sure but the
initialization should tell. Here is how I install Emacs [1]
But as for random-urandom feel free to - well, first tell me
what I should fix, then after that has been done God willing
if you want to use it wherever be my guest. Otherwise I'll
just put it on my web pile.
Hey! Is there a "CELPA" perhaps for Emacs C? Put it there <3
> you could rewrite the function to return the value via a pointer, e.g.
>
> int
> get_random_number(uint32_t *n)
> {
> /* do stuff */
> if (succeeded) {
> *n = the random number;
> return 0;
> }
> return -1;
> }
>
> /* later */
>
> uint32_t n;
> if (get_random_number(&n) == -1) {
> /* Ooops */
> }
Yeah, but what then? That's just moving the situation.
The random number is returned as an emacs_value, see the
source [2] - perhaps one can send a nil emacs_value
instead of using the make_integer ...
> You should also consider why that was good for pwgen.
> If something is good for program A, it may not be "good
> enough" for program B. I don't know pwgen, but given that's
> in the first section of the manual is probably a program
> that generates a password, print it to stdout and quits.
> It doesn't have bottlenecks.
It has _randomness_, and more so than `random'.
> A program like Emacs on the other hand needs to call that
> function possibly multiple times, so investigating a bit for
> a faster way to obtain good random number is worth it IMHO.
Yeah, every history need a bit of polishing, as does every
program ...
So TODO, don't exit(1), and see if there is a speed
disadvantage compared to `random' ... what else?
[1] https://dataswamp.org/~incal/conf/.zsh/install-emacs
[2] https://dataswamp.org/~incal/emacs-init/random-urandom/random-urandom.c
--
underground experts united
https://dataswamp.org/~incal
next prev parent reply other threads:[~2021-11-07 9:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-06 16:35 urandom number in Emacs Emanuel Berg via Emacs development discussions.
2021-11-07 0:13 ` Emanuel Berg via Emacs development discussions.
2021-11-07 8:22 ` Omar Polo
2021-11-07 8:49 ` Emanuel Berg via Emacs development discussions.
2021-11-07 8:53 ` Omar Polo
2021-11-07 9:28 ` Emanuel Berg via Users list for the GNU Emacs text editor [this message]
2021-11-07 8:58 ` Emanuel Berg via Emacs development discussions.
2021-11-07 19:47 ` Emanuel Berg via Emacs development discussions.
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=874k8omi0t.fsf@zoho.eu \
--to=help-gnu-emacs@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=moasenwood@zoho.eu \
/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).