Skip to main content

Tweak Tutorial

Andreas posted a BankAccount and ATM tutorial. This nicely demonstrates some of the basic Tweak concepts such as fields, events, triggers, and handlers, as well as introducing UI aspects like players, costumes, updating etc.

Comments

Anonymous said…
Thanks for the tutorial. I noticed one problem however, In the balance method of BankAccount bewareOf: should be something like beAwareOf:. To 'beware of' means to 'be careful', 'be wary', 'be on guard' because of expected danger. To 'be aware of' means to 'be cognizant of', to 'know about'.
Vanessa said…
"To be on guard" is actually the meaning we intended - if someone wants to react to changes in this field, he needs to look for the event specified. It's like a flag or sign that signals "danger ahead, this has changed, please act accordingly, proceed with caution". We pondered various anntoations but settled on this.

However, neither of us is a native speaker, so we may well get convinced otherwise if you have a really good suggestion (beAwareOf: feels a bit awkward, too).
Anonymous said…
I agree beAwareOf: is awkward but I thought "be aware of this event" was what you actually meant.

Telling an object to beware of a normal event doesn't make sense to me. The update of a field value is not an abnormal or unexpected or dangerous event. Perhaps you mean beware because there's a danger you will overlook implementing a handler for this event that you probably really want to handle. But thats really a warning to the programmer rather than a message to the object.

How about beReadyFor: or respondTo: or watchFor: or takeActionOn: or the more prosaic but typical registerEvent:.

Don't know if you'll like any of these. In my opinion there all better than the implications of danger in bewareOf:. From what I've read, both you and Andreas express yourselves in English very well but you might want to solicit more input from other native speakers on this. I'm American by the way.

Cheers
Anonymous said…
Sorry, my second paragraph shows I didn't read your explanation carefully enough. That paragraph could be worded a bit differently but in general I object to telling an object that there is 'danger ahead' and that it should 'proceed with caution' because of a normal event.
Vanessa said…
I've taken the discussion to the mailing list.

Popular posts from this blog

Deconstructing Floats: frexp() and ldexp() in JavaScript

While working on my  SqueakJS VM, it became necessary to deconstruct floating point numbers into their mantissa and exponent parts, and assembling them again. Peeking into the C sources of the regular VM, I saw they use the  frexp ()   and ldexp () functions found in the standard C math library. Unfortunately, JavaScript does not provide these two functions. But surely there must have been someone who needed these before me, right? Sure enough, a Google search came up with a few implementations. However, an hour later I was convinced none of them actually are fully equivalent to the C functions. They were imprecise, that is, deconstructing a float using frexp() and reconstructing it with ldexp() did not result in the original value. But that is the basic use case: for all float values, if [ mantissa , exponent ] = frexp (value) then value = ldexp ( mantissa , exponent ) even if the value is subnormal . None of the implementations (even the complex ones) re...

Smalltalk Bindings for Minecraft Pi

The Raspberry Pi is a cute little computer. Quite cheap at $35, you plug in USB keyboard+mouse and a TV as monitor. And it is surprisingly capable, even for running 3D games. One particularly interesting game is Minecraft: Pi Edition . As in other Minecraft versions, the main goal is to create a world. But unlike other versions, you can not only use the tools provided by the game, you can make your own tools! That's because it comes with a programming interface. The Minecaft world is made of little cubes, and you normally place or remove these blocks by hand, one after another. This is fun, but for larger structures also quite cumbersome. For example, this rainbow here might take a long time to construct manually: But I did not make the rainbow by hand. I programmed it, using the Smalltalk programming language. It's just these dozen lines of code in the Squeak programming environment: Squeak is already installed on the Raspberry Pi, because Scratch was made in Squea...

SqueakJS: A Lively Squeak VM

I'm proud to announce SqueakJS, a new Squeak VM that runs on Javascript: SqueakJS project page It was inspired by Dan's JSqueak/Potato VM for Java, and similarly only runs the old Squeak 2.2 mini.image for now. But I developed it inside the Lively Kernel, which allowed me to make a nice UI to look inside the VM (in addition to all the Lively tools): It represents regular Squeak objects as Javascript objects with direct object references. SmallIntegers are represented as Javascript numbers, there is no need for tagging. Instance variables and indexable fields are held in a single array named "pointers". Word and byte binary objects store their data in arrays named "bytes" or "words". CompiledMethod instances have both "pointers" and "bytes". Float instances are not stored as two words as in Squeak, but have a single "float" property that stores the actual number (and the words are generated on-the-fly w...