On 08 Jan 2011, at 23:07, Nicolas Cellier wrote:
You mean something like:
| collec | collec := #('foo' 'bar'). shallowCopy := collec copy. self assert: collec first == shallowCopy first
Well, yes those copies are shallow, but what's the difference between copy, copyFrom:to: first, first: etc... with this respect ?
I think Stephan intended to say that the return result of #first is not a copy of (parts of) the receiver. #first is an accessor, not a copy message. And yes, the rule of thumb is that one reads the comments (or implementation) of a method to understand it, rather than (only) trying to guess it's semantics from its selector. We all got used to coding like that in Smalltalk. However, it's _just_ a rule of thumb that comments on top of the method body should document the method. Not all methods do it, and people coming from different languages and development environments are not immediately comfortable because they 'need to look at the implementation of an API to understand it'. So, I think there is something we can learn from other development environments: in XCode, for example, you can request the documentation of a method in a small 'hover window' by a <ctrl>+<click> on the method name. I wonder if such a system in Smalltalk development environment would make documenting a method more important, and thus, force people to write and use it more.... Johan