I'm curious. What name would you suggest?

Note that what I said below applies here; shuffling is what is the
intended use of rand.Shuffle. It could conceivably be used for
alternative things, but then C's sprintf can be used for writing to
arbitrary memory, though that is not what is intended. Should sprintf
be renamed to "writememory"?

ApplyFisherYatesIndexPairsToFunc would be the most accurate (beyond
just making the code be the documentation), but that then depends on
the user knowing that Fisher-Yates is a shuffling mechanism in the
common case, and knowing what Fisher-Yates does in the general case.
The current situation leads someone who's looking to shuffle something
to the function, and then provides two examples to show how that works.

There is obviously some assumed common knowledge, but without that
assumption things become untenable.

On Tue, 2018-10-16 at 10:39 +1000, Neil Higgins wrote:
> I would ascribe metaphysicality to the current name, and
> comprehensibility to a more accurate name. In this case, “shuffling”
> is just an example of what can be done. Abstraction is all very nice,
> until any applied meaning is completely lost in mumbo-jumbo.
>
> Neil Higgins (iPhone)
> higgins-dem...@bigpond.com
>
> >
> > On 16 Oct 2018, at 10:20 am, Dan Kortschak <dan.kortschak@adelaide.
> > edu.au> wrote:
> >
> > But this is not really what it does. You can see from the output of
> > this code https://play.golang.org/p/88Llo7zHTeK
> >
> > ```
> > package main
> >
> > import (
> > "fmt"
> > "math/rand"
> > )
> >
> > func main() {
> > rand.Shuffle(10, func(i, j int) {
> > fmt.Println(i, j)
> > })
> > }
> > ```
> >
> > That `i` is not sampled from a random distribution, but in fact
> > counts
> > down from the last index.
> >
> > This is an implementation of the Fisher-Yates shuffle https://golan
> > g.or
> > g/src/math/rand/rand.go?s=7456:7506#L225
> >
> > The reason that rand.Shuffle is called Shuffle is that that is it's
> > intention. Just as sort.Sort has the intention of sorting things,
> > but
> > needn't necessarily (https://play.golang.org/p/VdMuiFfcp6w).
> >
> > If we want to get metaphysical, nothing that we get the machine
> > todo
> > intrinsically means anything beyond what meaning we ascribe to it
> > (under some transformation or set of bases). This is why we name
> > things
> > and why those names matter.
> >
> > >
> > > On Tue, 2018-10-16 at 08:49 +1000, Neil Higgins wrote:
> > > So as well as getting rid of the euphemistic name, the
> > > documentation
> > > should simply say that it delivers n pairs of random numbers in
> > > the
> > > relevant range to a user-defined function.
> > >
> > > Neil Higgins (iPhone)
> > > higgins-dem...@bigpond.com
> > >
> > > >
> > > >
> > > > On 16 Oct 2018, at 8:31 am, Neil Higgins <1955ne...@gmail.com>
> > > > wrote:
> > > >
> > > > Well, ok. But I would call “Shuffle” a misleading misnomer,
> > > > because
> > > > until the user defines a shuffler function (which perversely
> > > > might
> > > > not, or might fail to, shuffle anything), it does not shuffle
> > > > anything.
> > > >
> > > > Thanks for taking the time to answer my question. Neil

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to