Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^3: a look at Sub::Genius with the debugger, and use v in 2021

by oodler (Initiate)
on Jun 28, 2021 at 11:31 UTC ( #11134390=note: print w/replies, xml ) Need Help??


in reply to Re^2: a look at Sub::Genius with the debugger, and use v in 2021
in thread a look at Sub::Genius with the debugger, and use v in 2021

Aldebaran, thanks for the kind words and welcome. I'll reply to a few things to get a handle on what direction you're heading.
The truth is that I don't get what goes wrong here, but I think I've framed where it happens. The scoping is hard for me to get my head around, but is it not the implementation of an AST?

The AST is only relevant when it comes to the construction of the DFA that is ultimately used to produce a single valid line of execution. Sub::Genius just takes what FLAT is able to generate as a string derived from the PRE (by way of an equivalent DFA). Are you trying to figure out how to go from the PRE to the DFA? An AST is involved in the conversion from the PRE to the PFA, but after that it is not involved at all.

Thank you for the pointer to the work of the Borweins, I am not a math guy but do enjoy reading about the subject and interesting people around it. Numerical errors notwithstanding, here are some suggestions that I think can help:
  • any word in the PRE represents a subroutine that is called when the "plan" is run; you have access to all the good stuff perl provides, such as AUTOLOAD; this was just a demo of handling subroutines that were not explicitly defined
  • the stubby utility has a new "list" subcommand that will take a PRE and list all valid orderings implied; I added this as a way to more easily see what execution orderings of the subroutines you were admitting
  • there is an error in the pi examples that are corrected in the latest release on CPAN - NUM_THREADS should be 6; but I think you figured that out
  • all parts of perl's memory model hold, see below for what I mean.
Here's an example of running stubby to list all possible valid subroutine execution orderings:
$ stubby list -p "begin ( sub1 & sub2 & sub3 ) end" begin sub1 sub3 sub2 end begin sub1 sub2 sub3 end begin sub2 sub1 sub3 end begin sub2 sub3 sub1 end begin sub3 sub1 sub2 end begin sub3 sub2 sub1 end
Regarding perl's memory model, you may program all subroutines assuming that they can access:
  • globaly variables
  • state variables defined within each sub (to create coroutines)
  • an additional execution scope represented by $scope that can be initialized (or not), then treated as an accumulator that is passed into each sub call and returned via each sub call
My contention is that using the right plan and correct use of the "memory" space, any implicitly shared memory algorithm may be implemented correctly. This remains to be seen, but that's my gut feeling. Note - everything is run sequentially in the perl runtime - thought, there is nothing stopping you from using fork; but that just gets us back to the realities of perl being fundamentally a uniprocess.
Hope that helps! Feel free to send me links to some stuff you've played with here - obviously, PM is not ideal for really swapping code. :-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11134390]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2022-01-28 05:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (73 votes). Check out past polls.

    Notices?