108108Unquote (` , ` ) also has a cousin called unquote-splicing ` ,@ ` which can insert
109109an array of stuff all at once.
110110
111- For example, if you want to create a shorthand ` mean ` for calculating the mean
112- of some numbers , you could do
111+ For example, if you want to create a shorthand ` mean ` for creating the
112+ expression necessary to calculate the mean of some variables , you could do
113113
114114<!-- !test in mean macro -->
115115
@@ -128,18 +128,18 @@ of some numbers, you could do
128128 ; Return a division of the sum of the arguments by the total
129129 (return `(/ (+ ,@args) ,total))))
130130
131- (mean 1 2 3 )
131+ (mean 1 2 a )
132132
133- which effectively creates the eslisp code ` (/ (+ 1 2 3 ) 3) ` that compiles to JS
133+ which effectively creates the eslisp code ` (/ (+ 1 2 a ) 3) ` that compiles to JS
134134as—
135135
136136<!-- !test out mean macro -->
137137
138- (1 + (2 + 3 )) / 3;
138+ (1 + (2 + a )) / 3;
139139
140140If we had used the plain unquote (` , ` ) instead of unquote-splicing (` ,@ ` ), we'd
141- have gotten ` (/ (+ (1 2 3 )) 3) ` which would compile to nonsense JS, as eslisp
142- would think ` (1 2 3 ) ` was a function call when ` 1 ` isn't a function.
141+ have gotten ` (/ (+ (1 2 a )) 3) ` which would compile to nonsense JS, as eslisp
142+ would think ` (1 2 a ) ` was a function call when ` 1 ` isn't a function.
143143
144144If you don't want to use ` quasiquote ` /`` ` `` & co., and think it's clearer for
145145your use-case to just work with objects, you can still always do that.
0 commit comments