unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Juanma Barranquero" <lekktu@gmail.com>
Subject: Re: Back to emacsclient/server
Date: Sat, 28 Oct 2006 23:16:29 +0200	[thread overview]
Message-ID: <f7ccd24b0610281416m248bce55s22d2eb467fc3dbec@mail.gmail.com> (raw)
In-Reply-To: <E1Gdib0-0004mn-Ua@fencepost.gnu.org>

On 10/28/06, Richard Stallman <rms@gnu.org> wrote:

> Let's make (random 'random) generate a new seed, use it, then restore
> the old one, so that it has no effect on the sequence. This is a much
> smaller change than adding a means to read and set the random seed.

On one hand, both are really equivalent. To restore the old seed you
first need a way to get it. The current random code in sysdep.c tries
to massage wildly different random implementations (lrand48, rand,
etc.) into a consistent interface, and there's no support in place *at
all* for getting back the seed (which also varies quite a lot across
implementations of random functions). I don't think is very sensible
to hastily add now a mechanism for getting the seed which, to make any
sense, should have to be heavily tested in as much environments as
possible.

On the other hand, I don't quite get what you're proposing. Currently,
the output of (random t) is almost never used, because when you're
passing t you cannot pass N. In the Emacs sources, (random) is used
about 7 times, while (random N) is used approx. 70. But your proposed
(random 'random), if I'm understanding you, would save the seed,
return a value, then restore the seed. For that to be useful, it'd
have to be (random N 'random). Moreover,
the current `random', when passed t, does:

    seed_random (getpid () + time (NULL));

So in many situations, when several values are needed at once (as is
the case in server.el), the code using your 'random would be:

  loop N times
     save seed
     set seed to (getpid () + time (NULL))
     collect a random value
     restore seed
  end loop

I very much doubt the result is hardly random enough; in fact,
getpid() + time(NULL) is bound to return the same value for a lot of
consecutive calls... To make that useful we'd need a way to get N
values at once from random.

But I think that's all unnecessary right now. As others have pointed
out, several packages already do initialize the random seed for
trivial reasons; I see no harm in doing the same in server.el. If your
proposal (or any variant) is ever implemented, fixing server.el is a
one-line change.

                    /L/e/k/t/u

  reply	other threads:[~2006-10-28 21:16 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-23 14:14 Back to emacsclient/server Juanma Barranquero
2006-10-23 14:54 ` Jason Rumney
2006-10-23 19:48   ` Stefan Monnier
2006-10-23 21:17     ` Jason Rumney
2006-10-23 22:02       ` Andreas Schwab
2006-10-23 16:00 ` Ted Zlatanov
2006-10-23 20:09   ` Eli Zaretskii
2006-10-24  0:02     ` Ted Zlatanov
2006-10-24  4:35       ` Eli Zaretskii
2006-10-24 15:36         ` Ted Zlatanov
2006-10-24 17:31           ` Eli Zaretskii
2006-10-24 19:24             ` Ted Zlatanov
2006-10-24 22:22               ` Stefan Monnier
2006-10-25 16:33                 ` Ted Zlatanov
2006-10-25 11:46               ` Michael Olson
2006-10-25 12:38                 ` David Kastrup
2006-10-23 21:47   ` Juanma Barranquero
2006-10-23 23:50     ` Ted Zlatanov
2006-10-24  2:01   ` Stefan Monnier
2006-10-24 15:40     ` Ted Zlatanov
2006-10-24 18:17       ` Stefan Monnier
2006-10-24 19:31         ` Ted Zlatanov
2006-10-23 16:26 ` Jan D.
2006-10-23 19:52   ` Stefan Monnier
2006-10-23 20:35     ` Jan Djärv
2006-10-23 21:20       ` Jason Rumney
2006-10-23 21:59         ` Jason Rumney
2006-10-24  5:06         ` Jan Djärv
2006-10-24  8:37           ` Juanma Barranquero
2006-10-24 13:27           ` Jason Rumney
2006-10-23 21:57       ` Juanma Barranquero
2006-10-24  5:08         ` Jan Djärv
2006-10-24  7:32           ` Kim F. Storm
2006-10-23 19:46 ` Stefan Monnier
2006-10-23 21:54   ` Juanma Barranquero
2006-10-24  2:04     ` Stefan Monnier
2006-10-24  8:39       ` Juanma Barranquero
2006-10-27  0:27         ` Juanma Barranquero
2006-10-27 11:08           ` Juanma Barranquero
2006-10-27 12:21             ` Jason Rumney
2006-10-27 13:25               ` Stefan Monnier
2006-10-27 13:35                 ` Juanma Barranquero
2006-10-27 13:29               ` Juanma Barranquero
2006-10-27 13:50                 ` Slawomir Nowaczyk
2006-10-27 14:20                 ` Stefan Monnier
2006-10-27 15:18                   ` Juanma Barranquero
2006-10-28 18:13                     ` Richard Stallman
2006-10-30  1:02                     ` Stefan Monnier
2006-10-31  0:35                       ` Juanma Barranquero
2006-10-28  7:27             ` Richard Stallman
2006-10-28 21:16               ` Juanma Barranquero [this message]
2006-10-28 23:38                 ` Kim F. Storm
2006-10-30 13:33                 ` Richard Stallman
     [not found] ` <f7ccd24b0610271000p16dda672mb146860725d47e00@mail.gmail.com>
     [not found]   ` <45426C6B.10401@student.lu.se>
     [not found]     ` <f7ccd24b0610271400x343c7197jbd6b775f49834924@mail.gmail.com>
     [not found]       ` <454276CB.9000002@student.lu.se>
     [not found]         ` <f7ccd24b0610271419p51bf429fjf5fb548e613cd950@mail.gmail.com>
     [not found]           ` <45427A24.8020107@student.lu.se>
     [not found]             ` <f7ccd24b0610271438r64539e94j6b17c251b213a047@mail.gmail.com>
     [not found]               ` <45427F8E.5040507@student.lu.se>
     [not found]                 ` <f7ccd24b0610271700v472f9c53v43017fce05e761e9@mail.gmail.com>
2006-10-28  0:24                   ` Juanma Barranquero

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=f7ccd24b0610281416m248bce55s22d2eb467fc3dbec@mail.gmail.com \
    --to=lekktu@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).