author | Claus Gittinger <cg@exept.de> |
Mon, 27 May 2019 16:53:37 +0200 | |
changeset 24192 | 18512bf68422 |
parent 22311 | 5331770c9388 |
permissions | -rw-r--r-- |
2240 | 1 |
" |
2 |
COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
5351
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
12 |
"{ Package: 'stx:libbasic' }" |
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
13 |
|
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
14 |
Block variableSubclass:#VarArgBlock |
2239 | 15 |
instanceVariableNames:'' |
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Kernel-Methods' |
|
19 |
! |
|
20 |
||
21 |
!VarArgBlock class methodsFor:'documentation'! |
|
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
||
36 |
||
37 |
! |
|
38 |
||
39 |
documentation |
|
40 |
" |
|
41 |
VarArgBlocks are much like blocks, but can accept a variable |
|
42 |
number of arguments. They must be defined as a regular block, |
|
43 |
with 1 argument. When executed, the actual argument list is |
|
44 |
passed in that single argument (as a collection). |
|
45 |
||
8890 | 46 |
Create a variableArgument block by sending #asVarArgBlock to a regular |
2239 | 47 |
block. |
48 |
||
22311 | 49 |
This is a goody add-on, which may not be available/possible in other |
2240 | 50 |
smalltalk implementations. Do not use it if cross-platform |
51 |
portability is required. |
|
52 |
||
53 |
||
2239 | 54 |
[author:] |
22311 | 55 |
Claus Gittinger |
2239 | 56 |
|
57 |
[see also:] |
|
22311 | 58 |
Block |
2239 | 59 |
" |
60 |
! |
|
61 |
||
62 |
examples |
|
63 |
" |
|
64 |
the same block, evaluated with 2 or 5 arguments: |
|
22311 | 65 |
[exBegin] |
2239 | 66 |
|b| |
67 |
||
8890 | 68 |
b := [:args | Transcript show:'wow: '; showCR:args] asVarArgBlock. |
2239 | 69 |
|
22311 | 70 |
b value:'hi' value:'there'. |
2239 | 71 |
b value:'hello' value:'there' value:'how' value:'about' value:'this'. |
22311 | 72 |
[exEnd] |
2239 | 73 |
|
74 |
||
75 |
does it accept a variable number of arguments ?: |
|
22311 | 76 |
[exBegin] |
2239 | 77 |
|b| |
78 |
||
79 |
b := [:args | Transcript showCR:args]. |
|
80 |
Transcript showCR:(b isVarArgBlock). |
|
81 |
||
8890 | 82 |
b := [:args | Transcript showCR:args] asVarArgBlock. |
2239 | 83 |
Transcript showCR:(b isVarArgBlock) |
22311 | 84 |
[exEnd] |
2239 | 85 |
" |
86 |
||
87 |
"Created: 23.1.1997 / 04:57:26 / cg" |
|
88 |
! ! |
|
89 |
||
5351
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
90 |
!VarArgBlock class methodsFor:'initialization'! |
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
91 |
|
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
92 |
initialize |
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
93 |
"must clear the is-block flag bit in the class |
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
94 |
(otherwise, the VM might try to inline value-messages)" |
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
95 |
|
15093 | 96 |
|newFlags| |
97 |
||
22311 | 98 |
newFlags := (self flags |
99 |
bitClear:(Behavior flagBlock)) |
|
100 |
bitOr:(Behavior flagVarArgBlock). |
|
15093 | 101 |
self flags:newFlags. |
5351
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
102 |
|
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
103 |
" |
22311 | 104 |
self flags. |
5351
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
105 |
self initialize. |
22311 | 106 |
self flags. |
5351
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
107 |
" |
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
108 |
! ! |
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
109 |
|
2239 | 110 |
!VarArgBlock methodsFor:'evaluation'! |
111 |
||
112 |
value |
|
113 |
"evaluate the receiver with no block args." |
|
114 |
||
115 |
^ super value:#() |
|
116 |
||
117 |
"Created: 23.1.1997 / 04:57:49 / cg" |
|
118 |
! |
|
119 |
||
120 |
value:arg |
|
121 |
"evaluate the receiver with a single argument." |
|
122 |
||
123 |
^ super value:(Array with:arg) |
|
124 |
||
125 |
"Created: 23.1.1997 / 04:57:57 / cg" |
|
126 |
! |
|
127 |
||
128 |
value:arg1 value:arg2 |
|
129 |
"evaluate the receiver with two arguments." |
|
130 |
||
131 |
^ super value:(Array with:arg1 with:arg2) |
|
132 |
||
133 |
"Created: 23.1.1997 / 04:58:03 / cg" |
|
134 |
! |
|
135 |
||
136 |
value:arg1 value:arg2 value:arg3 |
|
137 |
"evaluate the receiver with three arguments." |
|
138 |
||
139 |
^ super value:(Array with:arg1 with:arg2 with:arg3) |
|
140 |
||
141 |
"Created: 23.1.1997 / 04:58:09 / cg" |
|
142 |
! |
|
143 |
||
144 |
value:arg1 value:arg2 value:arg3 value:arg4 |
|
145 |
"evaluate the receiver with four arguments." |
|
146 |
||
22311 | 147 |
^ super value:(Array |
148 |
with:arg1 |
|
149 |
with:arg2 |
|
150 |
with:arg3 |
|
2239 | 151 |
with:arg4) |
152 |
||
153 |
"Modified: 22.1.1997 / 19:41:22 / cg" |
|
154 |
"Created: 23.1.1997 / 04:58:14 / cg" |
|
155 |
! |
|
156 |
||
157 |
value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 |
|
158 |
"evaluate the receiver with five arguments." |
|
159 |
||
22311 | 160 |
^ super value:(Array |
161 |
with:arg1 |
|
162 |
with:arg2 |
|
163 |
with:arg3 |
|
2239 | 164 |
with:arg4 |
165 |
with:arg5) |
|
166 |
||
167 |
"Modified: 22.1.1997 / 19:41:26 / cg" |
|
168 |
"Created: 23.1.1997 / 04:58:18 / cg" |
|
169 |
! |
|
170 |
||
171 |
value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 value:arg6 |
|
172 |
"evaluate the receiver with six arguments." |
|
173 |
||
22311 | 174 |
^ super value:(Array |
175 |
with:arg1 |
|
176 |
with:arg2 |
|
177 |
with:arg3 |
|
2239 | 178 |
with:arg4 |
179 |
with:arg5 |
|
180 |
with:arg6) |
|
181 |
||
182 |
"Modified: 22.1.1997 / 19:41:29 / cg" |
|
183 |
"Created: 23.1.1997 / 04:58:22 / cg" |
|
184 |
! |
|
185 |
||
186 |
value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 value:arg6 value:arg7 |
|
187 |
"evaluate the receiver with seven arguments." |
|
188 |
||
22311 | 189 |
^ super value:(Array |
190 |
with:arg1 |
|
191 |
with:arg2 |
|
192 |
with:arg3 |
|
2239 | 193 |
with:arg4 |
194 |
with:arg5 |
|
195 |
with:arg6 |
|
196 |
with:arg7) |
|
197 |
||
198 |
"Modified: 22.1.1997 / 19:41:33 / cg" |
|
199 |
"Created: 23.1.1997 / 04:58:26 / cg" |
|
200 |
! |
|
201 |
||
202 |
value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 value:arg6 value:arg7 value:arg8 |
|
203 |
"evaluate the receiver with eight arguments." |
|
204 |
||
22311 | 205 |
^ super value:(Array |
206 |
with:arg1 |
|
207 |
with:arg2 |
|
208 |
with:arg3 |
|
2239 | 209 |
with:arg4 |
210 |
with:arg5 |
|
211 |
with:arg6 |
|
212 |
with:arg7 |
|
213 |
with:arg8) |
|
214 |
||
215 |
"Created: 23.1.1997 / 04:58:30 / cg" |
|
216 |
! |
|
217 |
||
218 |
valueWithArguments:argArray |
|
219 |
"evaluate the receiver with all arguments in argArray." |
|
220 |
||
221 |
^ super value:argArray |
|
222 |
||
223 |
"Created: 23.1.1997 / 04:59:16 / cg" |
|
224 |
! ! |
|
225 |
||
226 |
!VarArgBlock methodsFor:'testing'! |
|
227 |
||
228 |
isVarArgBlock |
|
229 |
"return true, if this block accepts a variable number of arguments" |
|
230 |
||
231 |
^ true |
|
232 |
||
233 |
"Created: 23.1.1997 / 05:00:18 / cg" |
|
234 |
! ! |
|
235 |
||
2240 | 236 |
!VarArgBlock class methodsFor:'documentation'! |
2239 | 237 |
|
2240 | 238 |
version |
22311 | 239 |
^ '$Header$' |
2240 | 240 |
! ! |
7589 | 241 |
|
15093 | 242 |
|
5351
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
243 |
VarArgBlock initialize! |