Hi,
I'm a Squeak/Smalltalk newbie with some experience of doing OO in other languages, chiefly VB (which is not at all great for that purpose) and Python (which is rather better, but not in use in my place of work), and a smattering of FP that's still not settled in my mind. I'm trying to get my head round a couple of things in Smalltalk, and the documentation I've browsed so far hasn't helped much: my queries more to do with idiom than anything else. Can anyone give me a clue as to where I might find some answers to questions like these:
* If I want to expose an instance's private fields, do I have to code accessor methods every time? Is there an alternative to writing
getFoo ^ foo
and
setFoo: newFoo foo := newFoo
over and over again?
* Is the best way to make what in C++ or Java you'd call "constructors" to write class methods that create, initialize and then return an instance, e.g.
newFooWithBar: initialBar | newFoo | newFoo := Foo new; setBar: initialBar. ^ newFoo
or is there a more concise way?
* Can I treat blocks as first-class entities, e.g. return them from methods, pass them around etc? Can I use them to implement LISP-like closures? Even if I can, is this a "natural" smalltalky way to do things?
* What about function/method pointers? Can I treat one of an instance's methods as a block, or do I have to make a new block and call the method inside that?
Finally,
* Is this list a good place to ask questions like this? If it isn't, is there a more suitable one?
thanks, Dominic