{ import Smalltalk/kernel } " pull in the Smalltalk kernel classes " Foo : Object ( bar ) " new prototype 'Foo' extends 'Object' with slots 'bar' and 'baz' " Foo new [ self := super _clone. " you can assign to self, if you are stylistically inclined to do so " " (note that 'super' refers to the prototype from which Foo was extended, " " in this case 'Object'; 'self _clone' too, or 'super new' would work too) " bar := 42. " assigns 'bar' in the *new* self object, *not* the original receiver " " implicit ^self returns the *new* self (duh) " ] Foo hiThere " Foo responds to hiThere like this... " [ 'Foo says ''Hi There!''' println ] { printf("You can include literal C code at the top level.\n"); } Foo dazzle: someone ... " '...' as in 'etc.' as in 'use more arguments, if you like' " [ | arguments next | arguments := OrderedCollection new. arguments add: someone. { va_list ap; va_start(ap, v_someone) }. " magic -- don't ask " [{ v_next= va_arg(ap, oop) }. " more magic -- this ugliness will soon go away " next notNil] whileTrue: [arguments add: next]. { va_end(ap) }. " last bit of magic -- still don't ask, this is all VERY temporary " ('Dazzling ', arguments printString) println. ] [ | stream | { printf("You can also include literal C code in top-level Smalltalk code.\n"); }. Foo hiThere. " BEWARE: a 'named prototype' has PRECISELY the same behaviour as ... " Foo new hiThere. " ... its anonymous clones! (see pseudobogus 'new' method in Smalltalk/Object.st) " Foo dazzle: 'me' : 'with' : 'magic' : nil. " for when you're not sure how many arguments you might need " stream := String new writeStream. stream nextPutAll: 'You ran the program like this: '. Smalltalk arguments do: [:argument | stream nextPutAll: argument; space]. stream contents println. ] " There's lots more to tell, but I'm too lazy. Go read the documentation. "