write arrays with brackets in tests
The tests spelled out (¤ ...), what [...] reads into, which nobody writes. The reader's own tests keep it: there it is the point.
This commit is contained in:
@@ -44,11 +44,11 @@
|
||||
(var pp _ (& p))
|
||||
(printf "pointers: %d %g\n" (. pp x) (. pp y))
|
||||
|
||||
(var table (¤ int 3))
|
||||
(= (¤ table 0) 10)
|
||||
(= (¤ table 1) 20)
|
||||
(var first _ (¤ table 0))
|
||||
(var second _ (¤ table 1))
|
||||
(var table [int 3])
|
||||
(= [table 0] 10)
|
||||
(= [table 1] 20)
|
||||
(var first _ [table 0])
|
||||
(var second _ [table 1])
|
||||
(printf "arrays: %d\n" (+ first second))
|
||||
|
||||
;; a for opens a scope, and its initializer is declared inside it
|
||||
@@ -103,7 +103,7 @@
|
||||
;; a brace initializer has no type of its own, but its elements solve
|
||||
;; the hole in the array type around it -- and the length stays as
|
||||
;; written, whether or not every slot is initialized
|
||||
(var squares (¤ _ 4) #(0 1 4 9))
|
||||
(var sparse (¤ _ 8) #(0 1))
|
||||
(printf "from elements: %d %d %d\n" (¤ squares 2) (¤ squares 3) (¤ sparse 7))
|
||||
(var squares [_ 4] #(0 1 4 9))
|
||||
(var sparse [_ 8] #(0 1))
|
||||
(printf "from elements: %d %d %d\n" [squares 2] [squares 3] [sparse 7])
|
||||
(return 0))
|
||||
|
||||
Reference in New Issue
Block a user