Execute SNUSP/D: Difference between revisions
Content added Content deleted
m (changed, _join_ state of new thread thread should be inherited from original thread) |
m (fixed description) |
||
Line 7: | Line 7: | ||
#Read the char in current code pointer as input, assign it to memory currently pointed to by memory pointer. |
#Read the char in current code pointer as input, assign it to memory currently pointed to by memory pointer. |
||
*'''* : join and wait tasks''' (telepathy): |
*'''* : join and wait tasks''' (telepathy): |
||
#A task |
#A task has a state property of free/join/wait; |
||
#A task is by default initialized as free-state; |
|||
⚫ | |||
#When a free-state task first executes this '''*''' command, the task enters into a join-state; |
#When a free-state task first executes this '''*''' command, the task enters into a join-state; |
||
#Then if a join-state task executes another '''*''' command, the task enters into a wait-state; |
#Then if a join-state task executes another '''*''' command, the task enters into a wait-state; |
||
#A wait-state task stops its execution, and waits until all alive tasks are |
#A wait-state task stops its execution, and waits until all alive join-state tasks are turning into a wait-state, which then all these wait-state tasks are return to free-state; |
||
#This command enables global synchronization of the tasks. |
#This command enables global synchronization of the tasks. |
||
#Difference to original specification: |
#Difference to original specification: |
||
Line 16: | Line 18: | ||
::*In this implementation, the order of execution is first-created-first-executed; |
::*In this implementation, the order of execution is first-created-first-executed; |
||
::*The original specification specifies that ''(&)SPLIT''-ed old thread skips the immediate code (see below a->b->c->d example), which may lead to anti-intuition codes (which is good for an esoteric language :). This implementation retain old-thread-skips-immediate-code behavior in ''BLOATED'' mode, but new-thread-skips-immediate-code in ''SUPERNATURAL'' mode ( A->B->C->D example). 1->2->...->8 is thread creation order in ''SUPERNATURAL'' mode. |
::*The original specification specifies that ''(&)SPLIT''-ed old thread skips the immediate code (see below a->b->c->d example), which may lead to anti-intuition codes (which is good for an esoteric language :). This implementation retain old-thread-skips-immediate-code behavior in ''BLOATED'' mode, but new-thread-skips-immediate-code in ''SUPERNATURAL'' mode ( A->B->C->D example). 1->2->...->8 is thread creation order in ''SUPERNATURAL'' mode. |
||
:::<code style="line-height: 1em;">$*&\==&\:&\:&\:=\<br> ; ~ ~ ~ ~ &\=> new(B)<br> ; 2A 3B 4C 5D \=> old(A)<br> ; \=!\=!\=!\===*..=.#<br> ; /=!/=!/=!/===*.=.=.#<br> ; 1b 6c 7d 8a & |
:::<code style="line-height: 1em;">$*&\==&\:&\:&\:=\<br> ; ~ ~ ~ ~ &\=> new(B)<br> ; 2A 3B 4C 5D \=> old(A)<br> ; \=!\=!\=!\===*..=.#<br> ; /=!/=!/=!/===*.=.=.#<br> ; 1b 6c 7d 8a &\=> old(a)<br> ; ~ ~ ~ ~ \=> new(b)<br> \==&/;&/;&/;=/ <br></code> |
||
⚫ | |||
⚫ | |||
⚫ | |||
#The code pointer will bounce back to the code space boundary in its reverse direction; |
#The code pointer will bounce back to the code space boundary in its reverse direction; |
||
#then forward and stop after the first '''^''' it encounter in normal direction. |
#then forward and stop after the first '''^''' it encounter in normal direction. |
||
#Example : |
|||
:::==a^A<=cp==B^==<=C^== |
|||
::when the code pointer cp heading into A's^, next turn, the code pointer will be in C. if no such ^ in the reverse direction, the code pointer will be in ''a'' next turn. |
|||
<d>module snud ; |
<d>module snud ; |
||
private import std.string, std.random ; |
private import std.string, std.random ; |