designate an initializer's element by its index
[3] in braces reached the writer as a subscript of one operand, and sexc died taking the second.
This commit is contained in:
@@ -6,7 +6,8 @@
|
||||
"array 10 20 30"
|
||||
"argument 6"
|
||||
"mixed 1 5"
|
||||
"read through a pointer 1 5")
|
||||
"read through a pointer 1 5"
|
||||
"by index 0 2 0 1")
|
||||
(return 0)
|
||||
|
||||
;;; `:' inside #(...) ends a type and makes the rest a C99 compound
|
||||
@@ -53,4 +54,8 @@
|
||||
(var c (struct point) #(struct point : (. pm x) (. pm y)))
|
||||
(printf "read through a pointer %d %d\n" (. c x) (. c y))
|
||||
|
||||
;; an element may be named by its index, as a field is by its name
|
||||
(var sparse [int 4] #([3] 1 [1] 2))
|
||||
(printf "by index %d %d %d %d\n" [sparse 0] [sparse 1] [sparse 2] [sparse 3])
|
||||
|
||||
(return 0))
|
||||
|
||||
Reference in New Issue
Block a user