From: Pip Cet <pipcet@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: master d582356: * src/fns.c (Frandom): Handle bignum `limit`s
Date: Fri, 5 Mar 2021 20:13:40 +0000 [thread overview]
Message-ID: <CAOqdjBcXHK-vBqZ3KQ60VCXYuh0O1_ycFPJCTP8c=_PvrZ1rNw@mail.gmail.com> (raw)
In-Reply-To: <jwv35x9e63h.fsf-monnier+emacs@gnu.org>
On Fri, Mar 5, 2021 at 7:56 PM Stefan Monnier <monnier@iro.umontreal.ca> 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
next prev parent reply other threads:[~2021-03-05 20:13 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210305170955.27732.27579@vcs0.savannah.gnu.org>
[not found] ` <20210305170957.AF99920E1B@vcs0.savannah.gnu.org>
2021-03-05 19:42 ` master d582356: * src/fns.c (Frandom): Handle bignum `limit`s Pip Cet
2021-03-05 19:56 ` Stefan Monnier
2021-03-05 20:13 ` Pip Cet [this message]
2021-03-05 20:34 ` Stefan Monnier
2021-03-06 7:42 ` Pip Cet
2021-03-06 8:44 ` Eli Zaretskii
2021-03-06 9:44 ` Pip Cet
2021-03-06 10:56 ` Eli Zaretskii
2021-03-06 13:22 ` Pip Cet
2021-03-06 14:45 ` Eli Zaretskii
2021-03-07 13:27 ` Pip Cet
2021-03-07 14:04 ` Eli Zaretskii
2021-03-07 14:21 ` Pip Cet
2021-03-07 15:22 ` Eli Zaretskii
2021-03-07 17:23 ` Pip Cet
2021-03-07 17:47 ` Eli Zaretskii
2021-03-07 18:37 ` Stefan Monnier
2021-03-07 19:54 ` Andrea Corallo via Emacs development discussions.
2021-03-07 19:55 ` Pip Cet
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAOqdjBcXHK-vBqZ3KQ60VCXYuh0O1_ycFPJCTP8c=_PvrZ1rNw@mail.gmail.com' \
--to=pipcet@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.