Hi Torsten,
I think there can be some value in having example code that shows things beyond just returning an object. However, I think there is significantly more value in examples that do return objects. That is why I would want to have example for the more valuable piece, and to eliminate confusions I would not even call the others example, but another word, like script:
exampleThatReturnsOneObject
<example>
^ ...
snippetThatDoesOrShowsSomething
<script> / <exampleScript> / <exampleCode>
^ ...
I still think that <script> is enough. The goal of these methods is to get the person to run them and observe the side effect, without reusing the result. That is what scripts typically do. It should be enough. As for the example* methods, most of them can be nicely decomposed into an <example> and possibly a <script>. It would be enough.
Here is more reasons why I would not change <example> now. Until now, nobody is really using the <example> except the code that is packaged in GT. The only problematic part is:
TigerDemo>> runDemo
<example>
^ self new runDemo
But this one does not even fit your definition of an example of code. It's merely a way to trigger the running of the instance. It so happens that the class is an example for something else, but this code is not an example. It's a script. So, it should be:
TigerDemo>> runDemo
<script>
^ self new runDemo
(this solution is already committed in the Athens repo)
This would not even be a new interpretation. In the image, there already exists scripts that trigger an example class:
DynamicSpecExample>> openOnNil
<script: '(DynamicSpecExample object: nil) open'>
...
ui openWithSpecLayout: layout.
Btw, the <example> check in the CompiledMethod>>isExampleMethod was added after the discussion about introducing <example> and this tended to unify the meaning with the current example* selectors. We did not catch this distinction at that time, but it is clearly a mismatch. So, the actual intention of <example> did not change at all, but isExampleMethod enforces a new contract on the original one.
So, really, let's not make a larger thing than we have to out of this. We really have *one* problem that is not even a problem. The solution from Athens should be fine now, and we could remove the <example> pragma check from isExampleMethod for now.
Cheers,
Doru