From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: random doesn't feel very random Date: Sun, 26 Aug 2012 20:50:22 -0400 Message-ID: References: <876288yh72.fsf@kanis.fr> <87wr0livd4.fsf@Rainer.invalid> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1346028637 17553 80.91.229.3 (27 Aug 2012 00:50:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 27 Aug 2012 00:50:37 +0000 (UTC) Cc: emacs-devel@gnu.org To: Achim Gratz Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 27 02:50:38 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1T5nXH-0003ZV-8I for ged-emacs-devel@m.gmane.org; Mon, 27 Aug 2012 02:50:35 +0200 Original-Received: from localhost ([::1]:60274 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T5nXF-0003N3-8L for ged-emacs-devel@m.gmane.org; Sun, 26 Aug 2012 20:50:33 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:53323) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T5nXA-0003Mw-4X for emacs-devel@gnu.org; Sun, 26 Aug 2012 20:50:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T5nX5-00048P-QU for emacs-devel@gnu.org; Sun, 26 Aug 2012 20:50:27 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:52343) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T5nX5-00047y-MF for emacs-devel@gnu.org; Sun, 26 Aug 2012 20:50:23 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAG6Zu0/O+KG6/2dsb2JhbABEtBGBCIIVAQEEAVYjBQsLDiYSFBgNJIgcBboJkEQDozOBWIMF X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="196757688" Original-Received: from 206-248-161-186.dsl.teksavvy.com (HELO pastel.home) ([206.248.161.186]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 26 Aug 2012 20:50:22 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 5F6E259401; Sun, 26 Aug 2012 20:50:22 -0400 (EDT) In-Reply-To: <87wr0livd4.fsf@Rainer.invalid> (Achim Gratz's message of "Sun, 26 Aug 2012 16:24:55 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.182 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:152855 Archived-At: > Therefore the PRNG should be seeded once at start-up, from a good > source of entropy. I tend to agree. > Given the widespread use of (random t) it should probably be made a > no-op and a separate API to provide a local state for application that > wish to control it for whatever reason should be made available. IIRC Emacs fails to seed its PRNG at start (IOW it is seeded with a constant), which is why many packages use (random t). So I think the right thing to do now is to do seed it at startup, then make (random t) a no-op. We could consider adding a way to get the PRNG state and reset it later, but since the PRNG state is Emacs-wide and Emacs is more like an OS than like an application w.r.t its packages, such an interface would need to allow several named PRNGs, so you'd call (random N ) to get the next "random" number from 's stream. Stefan