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