Skip to content

Commit 2ea5d45

Browse files
committed
Merge pull request #4 from acook/wv_rework
Square bracket syntax and arbitrary nesting for WV literals
2 parents 4d9da60 + 41e6543 commit 2ea5d45

File tree

15 files changed

+80
-66
lines changed

15 files changed

+80
-66
lines changed

examples/basic_objects.bl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ o-new
1010
:num print
1111

1212
;; create a WV slot
13-
. 'omg hai' print . greet:
13+
[ 'omg hai' print ] greet:
1414
;; call a WV slot
1515
:greet
1616

examples/catting_a_vector.bl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
''
55
('a' 'b' 'c' 'd')
66

7-
. 0 ato swap 0 rmo rot rot cat swap .
8-
. len 0 eq swap drop .
7+
[ 0 ato swap 0 rmo rot rot cat swap ]
8+
[ len 0 eq swap drop ]
99
until
1010

1111
drop

examples/fd-read.bl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
;; NOTE -> this will block and wait on input!
44

55
newq 0 read swap newq ;; Q for read-queue, hide FD, Q for work-queue
6-
.
6+
[
77
'' swap ;; create empty CV and bring recv Q back to top
8-
.. rot swap app swap .. ;; bring Cv to top, then item, append item, bring Q to top
9-
.. deq dup not .. ;; deq item, dup it, and make it boolean
8+
[ rot swap app swap ] ;; bring Cv to top, then item, append item, bring Q to top
9+
[ deq dup not ] ;; deq item, dup it, and make it boolean
1010
until ;; iterate over read-queue until we get to a nil
1111
drop drop ;; drop the EOF nil and read-queue
1212
enq ;; send CV over the other Q to the main thread
13-
. work ;; use work thread for read loop
13+
] work ;; use work thread for read loop
1414
deq print ;; deq will block waiting for a response

examples/logic.bl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
1
2-
. 'not zero!' print .
3-
. 0 eq not .
2+
[ 'not zero!' print ]
3+
[ 0 eq not ]
44
if
55

66
(1 2)
7-
. 'empty' .
8-
. 'not empty!' .
9-
. len 0 eq swap drop .
7+
[ 'empty' ]
8+
[ 'not empty!' ]
9+
[ len 0 eq swap drop ]
1010
either print

examples/loops.bl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
5 4 3 2 1 ;; some stuff we're going to reverse
44

55
s-new
6-
. swap push . ;; take whatever is in he @stack and put it into our user-stack
7-
.
6+
[ swap push ] ;; take whatever is in he @stack and put it into our user-stack
7+
[
88
depth 1 eq ;; compare the @stack depth with 1
99
swap drop ;; clean up our lingering number
10-
. until
10+
] until
1111

1212
$ swap push ;; promote our user-stack onto the $stack
1313
;; this means the user-stack becomes our new @stack

examples/object-child.bl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ o-new ;; This will be the parent object
55
child ;; And this creates a child object that checks the parent
66

77
swap ;; let's add some slots to the parent
8-
. self print . inspect: ;; this lets us check out what object we have
8+
[ self print ] inspect: ;; this lets us check out what object we have
99

1010
swap ;; bring the child back to the top
1111
:inspect ;; call the inspect slot on the child

examples/object-self.bl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
o-new
44

55
;; we can use self much like @ inside of slots to refer to the current object
6-
. self print . inspect:
6+
[ self print ] inspect:
77
:inspect
88

99
;; self also allows you to easily use other slots on the same object
10-
. 1 2 3 4 5 'I am an object: ' print self :inspect . pp:
10+
[ 1 2 3 4 5 'I am an object: ' print self :inspect ] pp:
1111
:pp

examples/print_types.bl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ s-new 1 push 2 push 3 push 4 push print '' print
1111
~1 print
1212

1313
'word vectors' print
14-
. 1 2 3 4 . print '' print
14+
[ 1 2 3 4 ] print '' print
1515

1616
'char vectors' print
1717
'1 2 3 4' print '' print

examples/queues.bl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ newq 1 enq
44
newq 2 enq
55
swap deq print drop
66
3 enq 4 enq
7-
. print . proq
7+
[ print ] proq

examples/talking_to_threads.bl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
newq newq ;; create send and receive queues
2-
.
3-
..
2+
[
3+
[
44
deq ;; will block if the queue is empty
5-
n-to-cv rot swap enq ;; convert number into a cv (string) and send back
5+
n-to-cv rot swap enq ;; convert number into a cv (string) and send back
66
swap ;; reorder queues so we can loop without confusion
7-
.. loop ;; using loop since it goes forever
8-
. work ;; start new thread and swap the queues
7+
] loop ;; using loop since it goes forever
8+
] work ;; start new thread and swap the queues
99

1010
swap ;; bring send queue to top
1111
1 enq 2 enq 3 enq 4 enq ;; send some numbers to be converted
1212

1313
0
14-
. 1 add .
15-
. 1000 eq .
14+
[ 1 add ]
15+
[ 1000 eq ]
1616
until drop ;; give the main thread busywork
1717

1818
swap q-to-v ;; get contents of receive Q as V

0 commit comments

Comments
 (0)