Chapter 6 - Constants
Pocket Smalltalk provides a convenient extension to Smalltalk to
support named constants. Named constants are similar to pool
dictionary entries in other Smalltalks, but with the following
differences:
- They have a different syntax: ##constantName
instead of PoolDictionaryEntry.
- They are defined centrally via the Constants Browser.
- They can only hold simple literal values: Strings, Arrays,
Integers, and so on.
- They can belong to a package and can be saved and loaded
along with that package.
Named constants can be used to hold values that would normally be
#include'd from the PalmOS header files if you were
programming in C. Thus, event type IDs, drawing modes, and many other
PalmOS constants are available as named constants, and can be used
without fear of "bloating" the size of your application.
Constants are created and edited using the Constants Browser.
Constants belong to named "categories" for documentation purposes, in
a similar manner as methods belong to message categories. Categories
for constants can be edited in the upper-left pane of the Constants
Browser. The upper-right pane holds the names of the constants in the
selected category. By selecting a constant, you can see its name in
the status line at the bottom of the window. You can create new
constants and rename or delete existing constants using the context
menu in the upper-right pane.
When you create a new constant, it is added to the default package.
When you save that package, the constants in that package are saved
along with the package. You can change the package a constant belongs
to by using the upper-right pane's context menu option Change
package....
Named constants are also used for another very important purpose: to
define "system properties". The IDE knows about a few constants and
uses their values to determine various attributes of the generated
.PRC file. When you start a new project, these constants are
initialized with reasonable default values and put in the
"uncommitted" package. If you modify one of these constants, you
should add it to the package for your application. The constants and
their effects are listed here:
- ##applicationTitle
- A String containing the title of your application.
- ##creatorID
- A 4-element String or a 4-element ByteArray containing the
Creator ID of your application. Every application must
have a unique Creator ID.
- ##debug
- Set to true if debugging information is to be added to the
compiled executable; false to omit the debugging
information.
- ##optimization
- Set to true to apply optimizations to the compiled code.
The code generation process takes longer when this option
is set.
- ##dataStackSize
- The number of slots to reserve for the Smalltalk data stack.
- ##callStackSize
- The number of slots to reserve for the Smalltalk call stack.
This limits the number of simultaneous nested method calls.
- ##objectTableSize
- The number of slots to reserve for the object table. This
limits the total number of simultaneous "live" objects
(including literals within methods).
- ##heapSize
- The number of 2-byte words to reserve for the Smalltalk
dynamic heap. Be sure to leave enough free dynamic memory
for PalmOS to operate effectively.
Andrew Brault (ajb@tiac.net)