Today's Smalltalk 4 You looks at collection limitations, and how they can be bypassed using streams. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:
If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.
You can also watch it on YouTube:
Today we'll take a look at streams and collections. We've pointed out before that streaming works across any collection (not just strings) - but streaming also "bypasses" some of the limitations built into some of the collection classes. Take an Array, for instance. Being fixed size, this will fail:
array := #(1 2 3 4).
array add: 5.
Normally, that's not an issue - you probably picked an Array because you had a fixed set of objects, and didn't need to grow it. But what if you did? Well, you can use a stream:
If you inspect the results, you'll see that you still have an Array, now with 5 objects rather than 4. It's actually a copy of the initial array, not the same one grown. You could, of course, accomplish the same thing via the transformations APIs:
Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.
Today's Smalltalk 4 You looks at how GUIs are constructed in ObjectStudio. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:
If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.
Today's Smalltalk 4 You looks at the sample browser that comes with ObjectSTudio - a useful repository of simple examples. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:
If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.
Today's Smalltalk 4 You looks at reflection using instance variable names. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:
If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.
You can also watch it on YouTube:
Today we'll put a few pieces together on reflection in Smalltalk. Let's assume that you've read some data from an external source into a dictionary, with data like this:
Now, what if you want to create an instance of class Person and fill it with that data - but not using the sort of slot binding approach assumed by #instVarAt:put:? Consider the following:
person := Person new.
dict keysAndValuesDo: [:key :value |
| msg |
msg := (key, ':') asSymbol.
person perform: msg with: value].
^person
Notice how we assume that the dictionary keys are the names of variables, and we construct the messages that get sent to the object. Realistically, you would want exception/error handling around that, for cases where the file format and the class format get out of synch - but that's the basic approach, and it's used commonly in Smalltalk.
Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.
Today's Smalltalk 4 You looks at configurations in Pharo - no more wondering which magical incantation to perform in order to get some code to load :). If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:
If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.
Today's Smalltalk 4 You looks at the emergency evaluator in Pharo. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:
If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.
Today's Smalltalk 4 You looks at the common way to look up Smalltalk class names (things differ a bit in VisualWorks and ObjectStudio). If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:
If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.
You can also watch it on YouTube:
Today we'll continue looking at reflection in Smalltalk. In most Smalltalk implementations (Cincom Smalltalk being the exception), there's one namespace (Smalltalk). Thus, looking up a class by name is simple:
That makes reading in data from a source (a file, for instance) that includes class names pretty easy - get the class name, create an instance, and then dump data in the variables as it's found in the file. We'll take a look at that next time.
Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.
Today's Smalltalk 4 You looks at the inspector that's used in the latest versions of ObjectStudio. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:
If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.
Today's Smalltalk 4 You looks at finding arbitrary strings in your ObjectStudio code. Turns out that this feature in OS is easier to use than the equivalent one in VisualWorks. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:
If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.
Today's Smalltalk 4 You looks at one of the low level API aspects of Smalltalk - #instVarAt: and #instVarAt:put:. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:
If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.
You can also watch it on YouTube:
Today we'll look at a way you can break encapsulation in Smalltalk - useful for some low level tasks (interfacing with databases, for instance) - but dangerous in general. Still, it's useful to know what you can accomplish, so long as you are also aware of the dangers. Consider this class:
Object subclass: #Person
classInstanceVariableNames: 'nextId '
instanceVariableNames: 'id first last '
classVariableNames: ''
poolDictionaries: ''
Now consider this code:
person := Person new.
person first: 'James'.
person last: 'Robertson'.
person instVarAt: 1
Execute that, and you should get back the value in 'id' = the first instance variable. Again this is not something you want to make use of on a normal basis. It can be useful when debugging (say you have a class without accessing methods), or when creating accessing frameworks for external data. Similarly:
person instVarAt: 1 put: 0.
Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.