On Wed, 30 Nov 2016, Tobias Pape wrote:
On 30.11.2016, at 00:34, Chris Muller asqueaker@gmail.com wrote:
Hey Tobias, it looks like you added a <generated> tag too. Traditionally, the purpose of such a tag is used by code-generating applications to let programmers know that a particular piece of code is the purview of the framework which generated it, so they would know not to change it since it could very likely be regenerated in the future, blowing away any custom changes they might make there.
But none of that is the case here. This is not to improve cooperation with a mysterious framework, but invoked directly by the developer out for a one-time convenience, just like when they use the clipboard. Such a tag could actually confuse or deter future developers from adding; e.g., lazy-initialization into the method, because its not part of a code-generating application.
IMO, we should not put a <generated> tag in one-time-generated getters and setters.
¯_(ツ)_/¯
what about <autoaccessor>? I'd rather to have a way to identify non-human made code, whether transient or permanent.
Why is that for this case?
(I would rather not use pragmas in these methods, because I don't see if they would ever be used. If I were really want to mark these methods, I'd use a different author or a category other than accessing.)
Levente
-t
On Tue, Nov 29, 2016 at 8:31 AM, commits@source.squeak.org wrote:
Tobias Pape uploaded a new version of Tools to project The Trunk: http://source.squeak.org/trunk/Tools-topa.721.mcz
==================== Summary ====================
Name: Tools-topa.721 Author: topa Time: 29 November 2016, 3:27:14.942944 pm UUID: 2d64a7b9-8dcb-46fd-9371-c9dcb3f9cfd1 Ancestors: Tools-mt.720
Accessor generation.
Makes for a nice class hook and pushes responsibility to the class.
=============== Diff against Tools-mt.720 ===============
Item was added:
- ----- Method: Behavior>>createGetterFor: (in category '*Tools-Browser-accessors') -----
- createGetterFor: aName
| code |
code := '{1}\ <generated>\\ ^ {1}\' withCRs format: {aName.}.
self compile: code classified: #accessing notifying: nil.!
Item was added:
- ----- Method: Behavior>>createInstVarAccessors (in category '*Tools-Browser-accessors') -----
- createInstVarAccessors
"Create getters and setters for all inst vars defined here,
except do NOT clobber or override any selectors already understood by me"
self instVarNames
collect: [:each | each asSymbol]
thenDo: [:instVar |
(self canUnderstand: instVar) ifFalse: [self createGetterFor: instVar].
(self canUnderstand: instVar asMutator) ifFalse: [self createSetterFor: instVar]].
- !
Item was added:
- ----- Method: Behavior>>createSetterFor: (in category '*Tools-Browser-accessors') -----
- createSetterFor: aName
| code |
code := '{1}: anObject\ <generated>\\ {2}{1} := anObject.\' withCRs
format: {aName. self settersReturnValue ifTrue: ['^ '] ifFalse: [''].}.
self compile: code classified: #accessing notifying: nil.!
Item was changed: ----- Method: Browser>>createInstVarAccessors (in category 'class functions') ----- createInstVarAccessors
"Create getters and setters for all inst vars defined at the level of the current class selection,
except do NOT clobber or override any selectors already understood by the instances of the selected class"
self selectedClassOrMetaClass
ifNotNil: [:aClass | aClass createInstVarAccessors].
- !
self selectedClassOrMetaClass ifNotNil:
[:aClass| | cr |
cr := String with: Character cr.
aClass instVarNames do:
[:aName | | newMessage setter |
(aClass canUnderstand: aName asSymbol) ifFalse:
[newMessage :=
aName, cr, cr,
' ^ ', aName.
aClass compile: newMessage classified: #accessing notifying: nil].
(aClass canUnderstand: (setter := aName, ':') asSymbol) ifFalse:
[newMessage :=
setter, ' anObject', cr, cr,
(aClass settersReturnValue ifTrue: [' ^'] ifFalse: [' ']),
aName, ' := anObject'.
aClass compile: newMessage classified: #accessing notifying: nil]]]!