Sub-Genius

 view release on metacpan or  search on metacpan

lib/Sub/Genius.pm  view on Meta::CPAN


L<Sub::Genius> generates a correctly ordered, sequential series of
subroutine calls from a declarative I<plan> that may be parallel or
concurrent in nature.  This allows a concurrency plan to be I<serialized>
or I<linearized> properly for execution in a uniprocess (or single CPU)
environment.

Sub::Genius introduces all the joys and pains of multi-threaded, shared
memory programming to the uniprocess environment that is C<perl>.

After all, if we're going to I<fake the funk out of coroutines> [4],
let's do it correctly. C<:)>

[6], an exposition of L<sequential consistency> in the I<Chapel> programming
language also provides quite an interesting read. Chapel itself is
interested, as are the other I<high productivity> high performance
computing languages that came out during the first decade of this century
(X10, Fortress, etc).

=head1 SYNOPSIS

lib/Sub/Genius.pm  view on Meta::CPAN



=head2 The Expressive I<Power> of Regular Languages

This module is firmly grounded on the power afforded in expressiveness by
using Regular Language properties to express concurrency. Expansion into
more I<powerful> languages such as I<context sensitive> or I<context free>
is not part of the goal. For anyone interested in this topic, it's a relevant to
consider that since symbols in the PRE are mapped to subroutine names; it
does add computational power when a subroutine is given a C<state> variable,
effectively turning them into I<coroutines>. Memory is power; it doesn't
provide unlimited power, but it is the thing that makes Context Sensitive
Languages more power than Regular Languages, etc.

Given the paragraph above, C<Sub::Genius> may also be described as a way to
explore more or more valid execution orderings which have been derived from
a graph that contains all valid orderings. This graph (the DFA) described
precisely by the PRE.

=head2 Use of Well Known Regular Language Properties

lib/Sub/Genius.pm  view on Meta::CPAN


When C<next> is called the first time, an interator is created, and the
first string is returned. There is currently no way to specify which
string (or C<plan>) is returned first, which is why it is important that
the concurrent semantics declared in the PRE are done in such a way that
any valid string presented is considered to be sequentially consistent
with the memory model used in the implementation of the subroutines.

Perl provides the access to these memories by use of their lexical variable
scoping (C<my>, C<local>) and the convenient way it allows one to make a
subroutine maintain persistent memory (i.e., make it a coroutine) using
the C<state> keyword. See more about C<PERL's UNIPROCESS MEMORY MODEL
AND ITS EXECUTION ENVIRONMENT> in the section above of the same name.

At this time C<Sub::Genius> only permits I<finite> languages by default,
therefore there is always a finite list of accepted strings. The list
may be long, but it's finite.

As an example, the following admits a large number of orderings in a realtively
compact DFA, in fact there are 26! (factorial) such valid orderings:

lib/Sub/Genius.pm  view on Meta::CPAN


=head1 AUTHOR

OODLER 577 E<lt>oodler@cpan.orgE<gt>

=head1 ACKNOWLEDGEMENTS

I<TEODESIAN> (@cpan) is acknowledged for his support and interest in
this project, in particular his work lifting the veil off of what
passes for I<concurrency> these days; namely, I<most of the "Async"
modules out there are actually fakin' the funk with coroutines.>. See
L<https://troglodyne.net/video/1615853053> for a fun, fresh, and informative
video on the subject.



( run in 0.244 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )