eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'VarArgBlock':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: VarArgBlock


Inheritance:

   Object
   |
   +--ExecutableFunction
      |
      +--CompiledCode
         |
         +--Block
            |
            +--VarArgBlock

Package:
stx:libbasic
Category:
Kernel-Methods
Version:
rev: 1.11 date: 2021/01/20 14:27:41
user: cg
file: VarArgBlock.st directory: libbasic
module: stx stc-classLibrary: libbasic

Description:


VarArgBlocks are much like blocks, but can accept a variable
number of arguments. They must be defined as a regular block,
with 1 argument. When executed, the actual argument list is
passed in that single argument (as a collection).

Create a variableArgument block by sending #asVarArgBlock to a regular
block.

This is a goody add-on, which may not be available/possible in other
smalltalk implementations. Do not use it if cross-platform
portability is required.

copyright

COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

initialization
o  initialize
must clear the is-block flag bit in the class
(otherwise, the VM might try to inline value-messages)

Usage example(s):

     self flags.
     self initialize.
     self flags.


Instance protocol:

evaluation
o  value
evaluate the receiver with no block args.

o  value: arg
evaluate the receiver with a single argument.

o  value: arg1 value: arg2
evaluate the receiver with two arguments.

o  value: arg1 value: arg2 value: arg3
evaluate the receiver with three arguments.

o  value: arg1 value: arg2 value: arg3 value: arg4
evaluate the receiver with four arguments.

o  value: arg1 value: arg2 value: arg3 value: arg4 value: arg5
evaluate the receiver with five arguments.

o  value: arg1 value: arg2 value: arg3 value: arg4 value: arg5 value: arg6
evaluate the receiver with six arguments.

o  value: arg1 value: arg2 value: arg3 value: arg4 value: arg5 value: arg6 value: arg7
evaluate the receiver with seven arguments.

o  value: arg1 value: arg2 value: arg3 value: arg4 value: arg5 value: arg6 value: arg7 value: arg8
evaluate the receiver with eight arguments.

o  valueWithArguments: argArray
evaluate the receiver with all arguments in argArray.

testing
o  isVarArgBlock
return true, if this block accepts a variable number of arguments


Examples:


the same block, evaluated with 2 or 5 arguments:
  |b|

  b := [:args | Transcript show:'wow: '; showCR:args] asVarArgBlock.

  b value:'hi' value:'there'.
  b value:'hello' value:'there' value:'how' value:'about' value:'this'.
does it accept a variable number of arguments ?:
  |b|

  b := [:args | Transcript showCR:args].
  Transcript showCR:(b isVarArgBlock).

  b := [:args | Transcript showCR:args] asVarArgBlock.
  Transcript showCR:(b isVarArgBlock)


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 27 Jul 2024 03:26:33 GMT