Sub-Genius
view release on metacpan or search on metacpan
lib/Sub/Genius/Extended.pod view on Meta::CPAN
resource (e.g., a file, memory, network port, etc).
=head2 The Expressive Power of Regular Languages
This module is grounded in the expressive power afforded by regular language
properties to express concurrency. Expansion into more powerful languages such as
context-sensitive or context-free is not part of the goal.
Since symbols in the PRE are mapped to subroutine names, computational power can
also be increased by giving a subroutine a C<state> variable, effectively turning
it into a coroutine. Memory is power. It does not provide unlimited power, but it
is what makes context-sensitive languages more powerful than regular languages.
Given the paragraph above, C<Sub::Genius> may also be described as a way to
explore more and more valid execution orderings derived from a graph containing
all valid orderings. This graph (the DFA) is described precisely by the PRE.
=head2 Use of Well Known Regular Language Properties
C<Sub::Genius> uses C<FLAT>'s ability to transform a regular expression (of the
regular-language variety, not a Perl regex!) into a deterministic finite automaton
lib/Sub/Genius/Extended.pod view on Meta::CPAN
L<FLAT> provides utilities to enumerate accepted strings. The underlying method
creates an iterator.
When C<next> is called the first time, an iterator is created and the first
string is returned. There is currently no way to specify which plan is returned
first, which is why concurrent semantics should be declared so that any valid
string is sequentially consistent with the implementationâs memory model.
Perl provides access to these memories via lexical scoping (C<my>, C<local>) and
persistent subroutine memory (coroutines) via C<state>.
At this time, C<Sub::Genius> only permits finite languages by default, therefore
there is always a finite list of accepted strings.
As an example, the following admits a large number of orderings: 26! such plans:
my $plan = join(q{&}, (a..z));
my $final_scope = Sub::Genius->new(preplan => $plan)->run_once;
Thus, the following will take a long time, but will complete:
lib/Sub/Genius/Extended.pod 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 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.
lib/Sub/Genius/Util.pm view on Meta::CPAN
long-running production systems.
=head2 Generated Subroutine Shape
When generating Perl code that corresponds to plan symbols, each
subroutine is emitted with a conventional structure compatible with
C<Sub::Genius::run_once>:
sub C {
my $scope = shift; # execution context
state $mystate = {}; # persistent state (coroutine-style)
my $myprivs = {}; # lexical scratch space
# --- implementation goes here ---
print qq{Sub C: placeholder\n};
return $scope;
}
This reflects the core Sub::Genius execution model, where a mutable
C<$scope> hash reference is threaded through the execution plan.
( run in 2.554 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )