![]() |
![]() ![]() ![]() ![]() ![]()
|
next newest topic | next oldest topic |
Author | Topic: Smalltalk Global variables |
Douglas Kraul Member |
![]() ![]() ![]() I am investigating ways of passing shared information (mostly Smalltalk data structures) between a number of cooperative Sounds and the use of global variables seems to be one of the only choices. I am also slowly accumulating a small library of reusable Smalltalk code, much of it long and complex, that I would like to make available for use in scripts. Again, since class creation is disabled in Kyma, defining global variables assigned "blocks" as pseudo-functions seems to be one of the only choices open. Is the use of Smalltalk global variables considered an appropriate practice in Kyma? For example is it 'encouraged" to do things like: Do such assignments become a permament part of the Kyma image and survive across restarting the program? Is there a better way to approach this? Thx, Doug IP: Logged |
SSC Administrator |
![]() ![]() ![]() Anything you put into the Smalltalk dictionary would not survive between sessions. If you'd like to try an experiment you could try saving your functions in Preferences. To do this, send a setting message to Preferences, e.g. Preferences fooBar: [:x :y | x+ y]. To access your function you would send Preferences an accessing message, eg. Preferences fooBar value: 1 value: 2 should return 3 when evaluated. I haven't tried storing a code block in preferences this way, but if you'd like to give it a try, the worst that can happen is that you have to recreate your preferences file. (All you would have to do is restart Kyma holding down the caps lock key in order to start up with no preferences. Then Kyma would save a new preferences file the next time you quit). Let us know if this works out for you. IP: Logged |
SSC Administrator |
![]() ![]() ![]() P.S. Try saving one code block and quitting Kyma to make sure that the block has been saved properly (before you go through the work of saving all of your functions). IP: Logged |
Douglas Kraul Member |
![]() ![]() ![]() Your suggestion of using Preferences seems to work quite well! I placed a pretty long block in a new association (Preferences foo: aBlock) and it worked as expected. It also survived across restarts of Kyma. One question: what is the selector to delete an association (Preferences removeAt: #foo does not work). I kind of like the brevity of the KymaPreferences class for storing and retrieving objects. Is there a similar class, or is it safe to create a new KymaPreferences object and use that. What I am looking to do is something like: Preferences DKFunctions: aKymaPreference and use constructs of the type "Preferences DKFunctions Foo value:" to invoke a stored function. Putting them all in an object (DKFunctions) would cut down on clutter in Preferences. Doug IP: Logged |
All times are CT (US) | next newest topic | next oldest topic |
![]() ![]() |
This forum is provided solely for the support and edification of the customers of Symbolic Sound Corporation.