VAST Documentation: Executing scripted Smalltalk code during image start up / Example broken ?

68 views
Skip to first unread message

Norbert Schlemmer

unread,
Dec 5, 2019, 3:45:56 AM12/5/19
to VA Smalltalk
Hello
the example seems to be incorrect.

Smalltalk at: #TEMP put: OrderedCollection new!
 
TEMP add
: '1'!
TEMP add
: '2'!
TEMP add
: '3'!
TEMP add
: '!!'! "Exclamation marks in the Smalltalk code must be doubled to avoid being interpreted as the end of a code chunk"
 
Transcript cr; show: 'This message will not show up because the system is not fully initialized yet.'!
 
PostStartup!
 
Transcript cr; show: 'TEMP = ', TEMP printString!
Smalltalk removeKey: #TEMP!

Tested with 9.2 / Output :

Bob Brodd

unread,
Dec 5, 2019, 2:39:47 PM12/5/19
to VA Smalltalk
Hi Norbert,

Maybe I am missing something, but not sure what you think is broken?  

Bob

Norbert Schlemmer

unread,
Dec 6, 2019, 3:44:42 AM12/6/19
to VA Smalltalk
Hi Bob
each statement has to end with an exclamation point.
regards, Norbert

Bob Brodd

unread,
Dec 6, 2019, 1:36:52 PM12/6/19
to VA Smalltalk
Ah .. each statement does not have to end with an exclamation point, but each code chunk in this file does need to as it uses the FileIn protocol for 'compiling/executing' the code.  You can choose to create code chunks in whatever manner you need. The prestartup section as written does require two code chunks, as each code chunk needs to be a compilable chunk of code. The creation of TEMP needs to be in its own chunk because the direct references to it that follow  would cause a compiler error (TEMP would not be known until after the code was executed).   It could be written in this manner though:

 Smalltalk at: #TEMP put: OrderedCollection new!

 
 TEMP add
: '1'.
 TEMP add
: '2'.
 TEMP add
: '3'.
 TEMP add
: '!!'.
 Transcript cr; show: 'This message will not show up because the system is not fully initialized yet.'!

 PostStartup!
 
 Transcript cr; show: 'TEMP = ', TEMP printString.
 Smalltalk removeKey: #TEMP!

 Bob

Bob Brodd

unread,
Dec 6, 2019, 2:58:19 PM12/6/19
to VA Smalltalk
btw ... here is a link to some documentation about the abt.cnf file you may find useful: 
Reply all
Reply to author
Forward
0 new messages