From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pip Cet Newsgroups: gmane.emacs.devel Subject: Re: master d582356: * src/fns.c (Frandom): Handle bignum `limit`s Date: Fri, 5 Mar 2021 20:13:40 +0000 Message-ID: References: <20210305170955.27732.27579@vcs0.savannah.gnu.org> <20210305170957.AF99920E1B@vcs0.savannah.gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8152"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Mar 05 21:15:11 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lIGqs-00020v-Px for ged-emacs-devel@m.gmane-mx.org; Fri, 05 Mar 2021 21:15:10 +0100 Original-Received: from localhost ([::1]:58242 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIGqr-0004rA-SF for ged-emacs-devel@m.gmane-mx.org; Fri, 05 Mar 2021 15:15:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49516) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIGq7-0004QU-Sq for emacs-devel@gnu.org; Fri, 05 Mar 2021 15:14:23 -0500 Original-Received: from mail-ot1-x32f.google.com ([2607:f8b0:4864:20::32f]:45188) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lIGq1-0007dq-Jd for emacs-devel@gnu.org; Fri, 05 Mar 2021 15:14:21 -0500 Original-Received: by mail-ot1-x32f.google.com with SMTP id d9so2979735ote.12 for ; Fri, 05 Mar 2021 12:14:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=BWp8nVm8cfvBLVdc8cZznkRbm6Re9WcZrWcCXoNtkgc=; b=Dmpo11vo4Y/ohU0SYehVaWVH/0aGdbmYnev46n6zeVaI11+npJzAzUue9ndBtg7Fr2 BZgGwbVYcYvmdpbeKqox0plVUNjeOjWy3R0xlorpS4mg3pphmCY21/m2pbIxtaGNzGTU DPNJp10xPHtJs7yTWNVzRqZENV22yzeqwCxpNWZU79FBF/moPsYvegE+w3rThbtXkJL2 sxnLUGUnbOPqRgo9zkFDGdzYfMwSKBzIuDWl/Pb5rHUu7i9yTmK8a9xsFGAQY8uw8uyl 6eNMUyktooXtKMtCLy+Q75wc11hNqkkkD9vy7lV7kxGs0B2zPGbq8h2k4Zz4rKfU46gs hvtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BWp8nVm8cfvBLVdc8cZznkRbm6Re9WcZrWcCXoNtkgc=; b=DP9X+4QNnVnMoZF/ls1KWPEyD1aU/kdPU068fc5B+Qkre7we5AFrE+K/OyY6gq8er8 ETvx1d5DN3fGoAt+Lvu6kOtohQUEiv1GwDpR6BhifaFrm9HhlCUWjPi+jYC3cSj6P/RP LDxWsh7JYuRfExdySgMoBCknPC0/ZpHA5M9qVuhA9q3FiU37n3iMLR2f6/V4kMiC8gvt AImybSJymmIKGrlmtGquNgf9Dybl5X6PYsBZ7Yo95PTnIK7Dwcq00b0UevQi18HvzrRv irEEVKembowY0ZdlQcaqHOs/g8xF52ysFcNYRrKidP9AFojgUrGwCkwux8HXC1JkaUCW LUZw== X-Gm-Message-State: AOAM530qKp1FI8u8TVQ/auPglgoC98QBIJnt4SS0WWNcatBIATa3f3kj o7eg2qTNOQiRZjbGsRFhIqwZHPfN3mnqCvrfhUM= X-Google-Smtp-Source: ABdhPJypgFzbsAso+sQpw7vXEbjeajfXQVh6uI2e2B9eJTn6VuGK43QUkPMCJ0By85grdrAxOw3DOOT7O5S7tn5fQYY= X-Received: by 2002:a05:6830:11d4:: with SMTP id v20mr9280310otq.287.1614975256279; Fri, 05 Mar 2021 12:14:16 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::32f; envelope-from=pipcet@gmail.com; helo=mail-ot1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:266039 Archived-At: On Fri, Mar 5, 2021 at 7:56 PM Stefan Monnier wrote: > >> -If @var{limit} is a positive fixnum, the value is chosen to be > >> +If @var{limit} is a positive integer, the value is chosen to be > >> nonnegative and less than @var{limit}. Otherwise, the value might be > > Should we add "with every value equally likely" here, or is that > > perfectly obvious? > > We could do that, yes. While I do understand what's a probability > distribution, that's about as far as much knowledge goes in this area, > so I'll let others take care of that. Some people get philosophical about PRNGs, and they might be upset about the mere suggestion that 2^N states can be used to generate an (N+K)-bit pseudo-random integer... > > That docstring always tricks me into thinking "oh, don't worry about > > passing something invalid, you'll get an error", when in fact, you get > > a fixnum. (random -1)? Random fixnum. (random 1.0)? Random fixnum. > > (random 'many)? Random fixnum. > > Yes, this sucks, but I didn't dare to fix it. > I did fix the negative bignum case, tho: it now signals an error ;-) But what if someone relied on that?! Let's add a defcustom for it! > > But I'm really writing to ask whether it might be a good idea to add > > float support while we're there. > > Could be: AFAIK we already have code for it in Calc, so it might be > a small matter of moving the code. I'm so glad you didn't suggest cl-random. > To be honest: I only added support for it because I wanted to write some > randomized tests for 64bit bindat support and my machine is using 32bit > pointers still ;-) Should work for that :-) > > And, all of this could happen in Lisp, couldn't it? Should it? > > You might be right: we should probably export just `get_random` (and the > seeding part) to ELisp and then write the rest in ELisp. And then we can get rid of the horror that is cl-random, too, right? Pip