Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: preliminary patch for zsh/random module
On Sun, Oct 23, 2022 at 7:57 PM Clinton Bunch <cdb_zsh@xxxxxxxxxxx> wrote:
>
> On 10/23/2022 9:01 PM, Bart Schaefer wrote:
> > * Typo in the introductory comment.
> I'm pretty sure I've since found and changed all the instances of
> Zoltan's name.
I was referring to the spelling of "randome".
> > Actual question: What's the use case for returning or printing a
> > block of random bytes? Why does this need to be a builtin?
> Mostly because I see constructs like read -k6 -u3 3</dev/urandom
... because?
> it would be nice to initialize an array with random numbers without
> having to use a loop to access SRANDOM n times.
But you're not filling an array with random numbers, you're filling a
string (scalar) with random bytes.
> > Suggestion: Treat SRANDOM like SECONDS, in that you can change the
> > type from integer to floating-point. Then maybe the zrandom() math
> > function isn't needed?
> That would seem confusing to me, and too easy to forget which state you
> left it in.
You make it local so you're not leaving it.
() {
print $SECONDS;
() {
local -F SECONDS
print $SECONDS
}
print $SECONDS
}
56
0.0000050000
56
> zrandom was meant to be a replacement for rand48
OK.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author