-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from acook/wv_rework
Square bracket syntax and arbitrary nesting for WV literals
- Loading branch information
Showing
15 changed files
with
80 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
1 | ||
. 'not zero!' print . | ||
. 0 eq not . | ||
[ 'not zero!' print ] | ||
[ 0 eq not ] | ||
if | ||
|
||
(1 2) | ||
. 'empty' . | ||
. 'not empty!' . | ||
. len 0 eq swap drop . | ||
[ 'empty' ] | ||
[ 'not empty!' ] | ||
[ len 0 eq swap drop ] | ||
either print |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ newq 1 enq | |
newq 2 enq | ||
swap deq print drop | ||
3 enq 4 enq | ||
. print . proq | ||
[ print ] proq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
;; basic demonstration of nested calls | ||
. | ||
.. | ||
[ | ||
[ | ||
0 | ||
.. call | ||
. call | ||
] call | ||
] call | ||
|
||
;; Smalltalk-style Conditionals | ||
|
||
o-new ;; o1 will house our truthy and falsey objects | ||
|
||
o-new ;; o2 (truthy object) | ||
. swap call . ;; evaluate the wv | ||
[ swap call ] ;; evaluate the wv | ||
if-true: ;; store function in slot | ||
. swap drop . ;; do nothing except get rid of the wv | ||
[ swap drop ] ;; do nothing except get rid of the wv | ||
if-false: ;; store function in slot | ||
true: ;; store o2 in slot in o1 | ||
|
||
o-new ;; o3 (falsy object) | ||
. swap drop . ;; do nothing except get rid of the wv | ||
[ swap drop ] ;; do nothing except get rid of the wv | ||
if-true: ;; store function in slot | ||
. swap call . ;; evaluate the wv | ||
[ swap call ] ;; evaluate the wv | ||
if-false: ;; store function in slot | ||
false: ;; store o3 in slot in o1 | ||
|
||
:false ;; summon reference to falsey o3 | ||
. 'I am so false.' print . ;; a WV to demonstrate the condition | ||
[ 'I am so false.' print ] ;; a WV to demonstrate the condition | ||
swap :if-false ;; call if-false on o3, will display "I am so false." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package main | ||
|
||
type ops_fifo struct { | ||
items [][]operation | ||
} | ||
|
||
func (f *ops_fifo) push(ops []operation) { | ||
f.items = append(f.items, ops) | ||
} | ||
|
||
func (f *ops_fifo) pop() []operation { | ||
ops := f.items[f.depth()-1] | ||
f.items = f.items[:f.depth()-1] | ||
return ops | ||
} | ||
|
||
func (f *ops_fifo) depth() int { | ||
return len(f.items) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters