Declaration syntax
The following attribute-value pairs are used in declarations in declaration methods.
name: anIdentifier
Specifies the name of the pool or variable to be declared.
The names are Smalltalk identifiers; that is, a sequence of one of more alphanumeric characters (including underscore) that begins with a nonnumeric character. For example:
(name: MyGlobal) isPool: aBoolean
isPool: aBoolean
Specifies whether a declaration is a pool or a variable.
If aBoolean is true, the declaration is a pool. If aBoolean is false or the attribute is omitted, the declaration is a variable. For example:
(name: MyPoolDictionary isPool: true)
pool: anIdentifier
Specifies the name of the pool in which to declare the name specified by name:, thereby making the name specified by name: a pool variable. The pool name is a Smalltalk identifier. For example:
(name: MyPoolVariable pool: MyPoolDictionary)
Pool variable declarations for a pool can be distributed over several declaration methods in an application namespace. The declaration methods can appear in the application or any of its subapplications. The pool declaration must be in only one declaration method or a declaration error results. An application cannot add pool variables to pools that are declared by other applications. Pool variables cannot be declared in a pool that is defined in another application namespace, even if the pool is visible or a declaration error results.
A pool cannot be declared as a pool variable within another pool. A declaration that specifies pool: and isPool: true generates a syntax error.
comment: aString
Specifies a comment string for the declaration. Some examples:
(name: LineDelimiter comment: 'Platform dependent value')
(name: ObsoleteGlobal comment: 'For compatibility purposes only')
isPublic: aBoolean
Controls the visibility of the declared name. If isPublic: is omitted or aBoolean is true, the visibility of the name extends to the namespace of any application that directly or indirectly includes the application containing the declaration as a prerequisite. If aBoolean is false, the name is private and is visible only within the namespace in which it is declared. An example:
(name: PrivateMagicalGlobal isPublic: false comment: 'Hidden magic value')
If the following are marked private, their names are not visible outside the application namespace:
Application variables
Pool variables
Pool variables within a pool dictionary
isConstant: aBoolean
Controls whether the name can be the target of an assignment at run time. If aBoolean is true, the variable cannot be assigned to. If aBoolean is false, the variable can be assigned to. For example:
(name: MyNilConstant isConstant: true)
If isConstant: is omitted, the value is assumed to be false. The result of using isConstant: in combination with isPool: is unspecified.
valueExpression: aString
Controls the initial value of the variable declared. If valueExpression: is omitted, the initial value of the variable declared is nil. The value expression is a string that must contain either a Smalltalk literal expression or a highly restricted, context-independent initialization expression. The initialization expression types are intentionally limited. Most variables require runtime executable initialization in the form of an assignment statement (for example, in a loaded or startUp method). Some examples:
(name: ConstantPi isConstant: true valueExpression: '3.141592654')
(name: UseDefaults valueExpression: 'true')
(name: CanInitializeOnlyConstants valueExpression: 'false')
Expression types for value expressions are the same as those permitted by declareConstant:value:. Those are the following types:
(name: X valueExpression: 'nil')
Boolean literals
(name: X valueExpression: 'true')
(name: X valueExpression: 'false')
Character literals and character values
(name: X valueExpression: '$X')
(name: X valueExpression: '31 asCharacter')
String literals
(name: X valueExpression: '''This is a literal string''')
(name: X valueExpression: '''This is a ''''quotable'''' literal string''')
To initialize a constant to a string value, the value expression must be a string containing literal quotes; otherwise, the string is evaluated. If the string value contains quotes, four quotes must be used, as in:
'''This is ''''quotable'''', isn''''t it?'''
Symbol literals
(name: X valueExpression: '#inactive')
(name: X valueExpression: '#''spaces in symbol''')
Numeric literals
(name: X valueExpression: '3')
(name: X valueExpression: '16rFFFF')
(name: X valueExpression: '3.0001')
Array literals
(name: X valueExpression: '#(1 2 3)')
(name: X valueExpression: '#(a b c)')
Byte array literals
(name: X valueExpression: '#[0 1 255]')
Platform function initializers
(name: Beep isConstant: true valueExpression: 'PlatformFunction fromArray: #(''C'' ''Beep'' nil ''kernel32.dll'' #(#uint32 #uint32) #bool)')
When declarations are processed, a value expression resets the value associated with an existing nonassignable variable. When declarations are processed, a value expression does not change the value associated with an existing variable that has not been explicitly declared as a nonassignable.
You cannot execute code in a value expression. You cannot access the value of variables from within a value expression. The value expressions are treated as load-time constants. Initializations are performed in no particular order within a namespace, but are performed before executing the application's loaded method.
declarations: ( <declaration>... )
Makes the declaration of pool variables more concise. It can be used only in combination with the pool: attribute. An example:
(pool: MyPool declarations: (
(name: MyPoolVar1)
(name: MyPoolVar2)
This is equivalent to:
(name: MyPoolVar1 pool: MyPool)
(name: MyPoolVar2 pool: MyPool)
pragma: aString
Tags a declaration with special information. The following declaration uses pragma: to add information to tag the declaration as an NLS pool and specify its catalog name.
(name: NlsCatKRN isPool: true pragma: 'NLS krn')
Do not use pragma: unless directed to do so by the documentation for products that extend basic VA Smalltalk. The interpretation of pragma: is not defined by VA Smalltalk.
Last modified date: 10/08/2020