Hello

Daniel Vainsencher danielv at netvision.net.il
Sun May 18 00:26:05 UTC 2003


Dominic Fox <dominic.fox1 at ntlworld.com> wrote:
> 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.
Welcome, I think you'll have fun.

> 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
...
> over and over again?
Some of the browsers (including the RefactoringBrowser) have menu
options to do this.

> * Can I treat blocks as first-class entities, e.g. return them from methods, 
> pass them around etc? 
Yes.

> Can I use them to implement LISP-like closures? 
Almost - they currently can't define their own local variables, but a
package that fixes that is available and will probably RSN become
standard.

> Even if 
> I can, is this a "natural" smalltalky way to do things?
It isn't taboo. It is one tool in your box as a Smalltalker. 

> * 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?
Making blocks in Squeak is cheaper than in LISP - 2 characters minimal
overhead +  2 char per parameter (3 for the first) '[:a|]' rather than
12 + 2 per parameter (1 for the first) '(lambda (a) )'. So it's a pretty
concise way to do callbacks. Sometimes #perform: or other tricks are
used instead.

> * Is this list a good place to ask questions like this? If it isn't, is there 
> a more suitable one?
A few answers to your question -
1. The definitive site for documentation is the swiki at
http://minnow.cc.gatech.edu/squeak/.
2. Smalltalk comes with lots of code, and tools to read and navigate it
- it should be an important part of how you find out how things are
done. 
3. This is just the place, and questions are welcomed.

Daniel



More information about the Squeak-dev mailing list