Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wdte: Call Queue #183

Open
DeedleFake opened this issue Apr 18, 2019 · 0 comments
Open

wdte: Call Queue #183

DeedleFake opened this issue Apr 18, 2019 · 0 comments

Comments

@DeedleFake
Copy link
Owner

DeedleFake commented Apr 18, 2019

The only difference between an iterative depth-first search and an iterative breadth-first search is that a DFS uses a stack to keep track of which nodes to search next and a BFS uses a queue. Due to the use of a stack, a recursive implementation of a DFS is quite simple, since the call stack essentially doubles as the frontier. A recursive BFS, on the other hand, often doesn't make sense. To that end, I would like to try a number of experiments with allowing pieces of code to be placed into a call queue rather than a stack, with the benchmark being that using this to create a recursive BFS is essentially the same as creating a recursive DFS.

Some things to note:

  • This is probably best accomplished either by having some type of subscope that modifies function call behavior inside it, or via some form of a Go-style defer-like system.
  • Generally during execution, conceptually, calling a function can be thought of as placing the contents of that function onto a stack, and executing an instruction can be thought of as popping the top of the stack. This makes thinking of how a queue would work relatively simple, with one major issue: Return values. With a stack, the code that uses the values returned is next to where they are returned from. With a queue, they're, potentially at opposite ends of the execution chain. How this should work, especially in a way that allows queued recursion to work, is the biggest problem at the moment.
  • The queuing needs to reach across the recursion. In other words, queuing a function inside of a recursive call needs to place the newly queued function into the same queue as the call it was made from. The simplest way to do this is probably to provide a way to create a named queue such that when a function is enqueued the user can specify onto which queue it is placed.
@DeedleFake DeedleFake self-assigned this Apr 18, 2019
@DeedleFake DeedleFake added this to Todo in Initial Implementation via automation Apr 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

1 participant