[m-users.] The new random module(s)

Julien Fischer jfischer at opturion.com
Thu Sep 5 21:09:17 AEST 2019


Hi Mark,

On Thu, 5 Sep 2019, Mark Brown wrote:

> On Thu, Sep 5, 2019 at 4:09 PM Julian Fondren <jfondren at minimaltype.com> wrote:
>>
>> In the permute_array/permute_list future,
>> will permute_X be added for other data structures?
>
> I wasn't planning to. Permutation is (mathematically) usually only
> defined for sets and sequences so I'm not sure what you'd be expecting
> for other library types. I suppose there could be a set permutation
> predicate that returns a randomly ordered list of the elements.
>
> In my view, the reason to put them in the random module is that they
> are more related to each other, and to the other predicates that do
> random stuff, than they are to predicates that merely work on lists or
> arrays. But no matter, I can add list.random_permutation now unless
> anyone else wants to add their opinion?

I disagree: I expect to find generic operations on lists in the list
module and generic operations on arrays in the array module.

> (array.random_permutation ought to wait until the old RNG has been
> sufficiently obsoleted. Note that I have only obsoleted the
> random.init predicate as that is sufficient to produce a warning, and
> declaring all predicates of the old implementation to be obsolete
> would only result in getting multiple warnings for essentially the
> same issue. I'll make that clearer in the docs for random.init.)

...

> So what's the choice?
>
> 1. Add random.permute_* (or whatever) now.
> 2. Add list.random_permutation and make a backwards incompatible
> change to array.random_permutation now.
> 3. Add list.random_permutation now, but wait before changing
> array.random_permutation.

I think we could avoid the namespace issues by naming the new versions
either:


     random.shuffle_list
     random.shuffle_array

or:

     list.random_shuffle
     array.randome_suffle

depending on where they end up (i.e. don't use the word permutation
or permute.)

We can always reclaim the name permutation after the old interface has
been removed.

Julien.


More information about the users mailing list