set_random VTABLE added to the Integer PMC
Andrew Whitworth
wknight8111 at gmail.com
Sun Oct 30 23:24:29 UTC 2011
Clarification, set_random is a METHOD, not a VTABLE.
I added this yesterday to address a problem I saw. libparrot has
several functions related to generating random numbers in src/util.c,
but does not expose any of that functionality by default. You must
load the math dynops library in order to get a user-accessible
interface to the PRNG. This seems stupid to me. If we're going for a
"lean" Parrot, that doesn't mean we include all the code in libparrot
but make the interfaces dynamically loadable.
So, either we do need a way to access the PRNG from base libparrot, or
we need to move the implementations out into a separate library. I
suggest the former, since random numbers are important for a variety
of tasks (hash seeds, GUID/UUID for packfiles, etc).
I don't know what is the best way to provide access. moving the
rand/srand dynops into core is one solution, but it seems like
something we don't really need ops for. PRNGs contain state (even if
that state is hidden behind libc or whatever our provider is) and
state implies something more object-like than op-like. That's just my
take. I'll gladly look into making a proper Random PMC type if that's
what people want (it has the benefit that it could be
subclassable/.hll_map-able).
--Andrew Whitworth
On Sun, Oct 30, 2011 at 7:18 PM, Jonathan "Duke" Leto <jonathan at leto.net> wrote:
> Howdy,
>
> I am not sure how I feel about the set_random VTABLE being added to
> the Integer PMC.
>
> At best, it should be marked experimental in api.yaml. At worst, it
> simply should not be there.
>
> plobsing++ suggested a core PMC which exposes the state of our random
> number generator.
>
> What do y'all think?
>
> Duke
>
> --
> Jonathan "Duke" Leto <jonathan at leto.net>
> Leto Labs LLC
> 209.691.DUKE // http://labs.leto.net
> NOTE: Personal email is only checked twice a day at 10am/2pm PST,
> please call/text for time-sensitive matters.
> _______________________________________________
> http://lists.parrot.org/mailman/listinfo/parrot-dev
>
More information about the parrot-dev
mailing list