An execution model inspired from thought stacks

  • 4 Replies
  • 364 Views
*

Zero

  • Trusty Member
  • ********
  • Replicant
  • *
  • 732
    • Thinkbots are free
An execution model inspired from thought stacks
« on: September 07, 2018, 10:42:04 am »
I think it's not a new programming paradigm, because this term encompass a lot of things. But it's an interesting execution model.

You probably know stack based languages, like Forth, Factor, Joy. Basically, you push operands on a data stack, then you push an operator which pops operands and pushes the result of the operation.

You also know how thoughts work. They work a bit like a stack. What you're thinking is on top of the stack. If that raises a problem, the problem get pushed on top of your thought stack, until it is solved. The solution is then left on the stack with the previous thoughts, and you can "resume" your prior thinking activities.

What gets pushed on the thought stack depends on what is already on the top. So a basic way to emulate a similar mechanism would be to use pattern matching to decide what to push.

Classical stack-based languages let you create a program; during execution, elements of the program are pushed one by one on the data stack. Here we do something different. We set up a rule engine, like those we use in chatbots, to match the top of the data stack against rules. When a rule fires, it pushes stuff on the data stack.

It's like saying "when the top of the data stack looks like this, push that on the data stack".

Here is an example.

data-stack:
    one two foo 4 3 +

rules:
    # # +    = <built-in sum>
    # # -    = <built-in sub>
    # baz    = baz was 1 #1 -
    # foo #  = bar between #1 and #2 baz

execution trace:
    one two foo 4 3 +
    one two foo 7
    one bar between two and 7 baz
    one bar between two and baz was 1 7 -
    one bar between two and baz was 6


I'm wondering whether I should include this in Airbender, or start fresh on another project, maybe in golang.
Thinkbots are free, as in 'free will'.

*

ranch vermin

  • Not much time left.
  • Terminator
  • *********
  • 958
  • Its nearly time!
Re: An execution model inspired from thought stacks
« Reply #1 on: September 08, 2018, 09:31:07 am »
I think you have to make them multidimensional,  so it has options when it pulls off a leaf.

Coincidentally, I love stacks too.  I know how to make a single number stack with algebra/complex sums.
I actually thought about this alot,  and if you put a video into a stack,  it comes back out playing backwards.

I bet you could get markov chains and palindromes to work in a stack.

 O0

*

Zero

  • Trusty Member
  • ********
  • Replicant
  • *
  • 732
    • Thinkbots are free
Re: An execution model inspired from thought stacks
« Reply #2 on: September 17, 2018, 03:31:30 pm »
What do you mean, "multidimensional"?
Sounds cool. :)
Thinkbots are free, as in 'free will'.

*

ranch vermin

  • Not much time left.
  • Terminator
  • *********
  • 958
  • Its nearly time!
Re: An execution model inspired from thought stacks
« Reply #3 on: September 17, 2018, 05:23:10 pm »
idea just simple one, but it backfired when i wasnt getting infinite memory from nothing  :idiot2:, a normal stack is 1d, u only push/pop the next item,  i mean just you get options each new pop/push whatever, so you have multiple stacks to pick from.

*

Zero

  • Trusty Member
  • ********
  • Replicant
  • *
  • 732
    • Thinkbots are free
Re: An execution model inspired from thought stacks
« Reply #4 on: September 17, 2018, 08:40:35 pm »
Reminds me of Push3, which has one data stack per data type. This one is for genetic evolution of programs. Pretty cool.
Thinkbots are free, as in 'free will'.

 


Users Online

64 Guests, 0 Users

Most Online Today: 116. Most Online Ever: 208 (August 27, 2008, 09:36:30 am)

Articles