Christoph Thiede uploaded a new version of ST80 to project The Inbox:
http://source.squeak.org/inbox/ST80-ct.255.mcz ==================== Summary ==================== Name: ST80-ct.255 Author: ct Time: 6 June 2020, 3:48:16.215278 pm UUID: 5469be3e-28ef-c54e-952c-674500374c05 Ancestors: ST80-nice.254 Fix Transcript in MVC projects if preference 'Force transcript updates to screen' is disabled. Thanks to Marcel (mt) for the hint! =============== Diff against ST80-nice.254 =============== Item was changed: ----- Method: PluggableTextView>>update: (in category 'updating') ----- update: aSymbol "Refer to the comment in View|update:. Do nothing if the given symbol does not match any action. " aSymbol == #wantToChange ifTrue: [self canDiscardEdits ifFalse: [self promptForCancel]. ^ self]. aSymbol == #flash ifTrue: [^ controller flash]. aSymbol == getTextSelector ifTrue: [^ self updateDisplayContents]. aSymbol == getSelectionSelector ifTrue: [^ self setSelection: self getSelection]. aSymbol == #clearUserEdits ifTrue: [^ self hasUnacceptedEdits: false]. (aSymbol == #autoSelect and: [getSelectionSelector ~~ nil]) ifTrue: [ParagraphEditor abandonChangeText. "no replacement!!" ^ controller setSearch: model autoSelectString; againOrSame: true]. + (#(#appendEntry appendEntryLater) includes: aSymbol) ifTrue: - aSymbol == #appendEntry ifTrue: [^ controller doOccluded: [controller appendEntry]]. aSymbol == #clearText ifTrue: [^ controller doOccluded: [controller changeText: Text new]]. aSymbol == #bs ifTrue: [^ controller doOccluded: [controller bsText]]. aSymbol == #codeChangedElsewhere ifTrue: [^ self hasEditingConflicts: true]. aSymbol == #saveContents ifTrue: [^self controller saveContentsInFile]. aSymbol == #close ifTrue: [^self topView controller closeAndUnscheduleNoTerminate]. aSymbol == #acceptChanges ifTrue: [^ self controller accept]. aSymbol == #revertChanges ifTrue: [^ self controller cancel].! |
Hi Christoph. Thanks. Given the overall style of this method, I would have rather duplicated those #appendEntry lines instead of using #includes:. Best, Marcel
|
Hi Marcel,
is duplication really desirable anywhere?
Hm ... ideally, I would love to rewrite such methods like this:
^ aSymbol caseOf: { [#wantToChange] -> [ self canDiscardEdits ifFalse: [self promptForCancel]]. [#flash] -> [controller flash].
[getTextSelector] -> [self updateDisplayContents].
"..."
{[#appendEntry]. [#appendEntryLater]} -> [
controller doOccluded: [controller appendEntry]].
"..." }
otherwise: [super update: aSymbol]
How would you think about such an extension to #caseOf:, accepting a list of cases, too? Would this be too meta? :-)
Best,
Christoph
Von: Squeak-dev <[hidden email]> im Auftrag von Taeumel, Marcel
Gesendet: Montag, 8. Juni 2020 07:19:16 An: squeak-dev Betreff: Re: [squeak-dev] The Inbox: ST80-ct.255.mcz
Hi Christoph.
Thanks. Given the overall style of this method, I would have rather duplicated those #appendEntry lines instead of using #includes:.
Best,
Marcel
Carpe Squeak!
|
> On 08.06.2020, at 09:45, Thiede, Christoph <[hidden email]> wrote: > > Hi Marcel, > > is duplication really desirable anywhere? I think what Marcel asks for is to stay in the style of the method as is. On top of thaT: > Hm ... ideally, I would love to rewrite such methods like this: > > ^ aSymbol > caseOf: { > [#wantToChange] -> [ > self canDiscardEdits ifFalse: [self promptForCancel]]. > [#flash] -> [controller flash]. > [getTextSelector] -> [self updateDisplayContents]. > "..." > {[#appendEntry]. [#appendEntryLater]} -> [ > controller doOccluded: [controller appendEntry]]. > "..." } > otherwise: [super update: aSymbol] > > How would you think about such an extension to #caseOf:, accepting a list of cases, too? Would this be too meta? :-) > Please don't. caseOf: should be used very sparingly. And IMHO it shouldn't be use to match an argument against a symbol. And by the way, the "aSymbol = #foo ifTrue: []"-style is prevalent for #update:-methods. You'll find that style in most classes using #changed:/#update: Best regards -Tobias > Best, > Christoph > Von: Squeak-dev <[hidden email]> im Auftrag von Taeumel, Marcel > Gesendet: Montag, 8. Juni 2020 07:19:16 > An: squeak-dev > Betreff: Re: [squeak-dev] The Inbox: ST80-ct.255.mcz > > Hi Christoph. > > Thanks. Given the overall style of this method, I would have rather duplicated those #appendEntry lines instead of using #includes:. > > Best, > Marcel >> Am 06.06.2020 15:48:26 schrieb [hidden email] <[hidden email]>: >> Christoph Thiede uploaded a new version of ST80 to project The Inbox: >> http://source.squeak.org/inbox/ST80-ct.255.mcz >> >> ==================== Summary ==================== >> >> Name: ST80-ct.255 >> Author: ct >> Time: 6 June 2020, 3:48:16.215278 pm >> UUID: 5469be3e-28ef-c54e-952c-674500374c05 >> Ancestors: ST80-nice.254 >> >> Fix Transcript in MVC projects if preference 'Force transcript updates to screen' is disabled. >> >> Thanks to Marcel (mt) for the hint! >> >> =============== Diff against ST80-nice.254 =============== >> >> Item was changed: >> ----- Method: PluggableTextView>>update: (in category 'updating') ----- >> update: aSymbol >> "Refer to the comment in View|update:. Do nothing if the given symbol does not match any action. " >> >> aSymbol == #wantToChange ifTrue: >> [self canDiscardEdits ifFalse: [self promptForCancel]. ^ self]. >> aSymbol == #flash ifTrue: [^ controller flash]. >> aSymbol == getTextSelector ifTrue: [^ self updateDisplayContents]. >> aSymbol == getSelectionSelector ifTrue: [^ self setSelection: self getSelection]. >> aSymbol == #clearUserEdits ifTrue: [^ self hasUnacceptedEdits: false]. >> (aSymbol == #autoSelect and: [getSelectionSelector ~~ nil]) ifTrue: >> [ParagraphEditor abandonChangeText. "no replacement!!" >> ^ controller setSearch: model autoSelectString; >> againOrSame: true]. >> + (#(#appendEntry appendEntryLater) includes: aSymbol) ifTrue: >> - aSymbol == #appendEntry ifTrue: >> [^ controller doOccluded: [controller appendEntry]]. >> aSymbol == #clearText ifTrue: >> [^ controller doOccluded: >> [controller changeText: Text new]]. >> aSymbol == #bs ifTrue: >> [^ controller doOccluded: >> [controller bsText]]. >> aSymbol == #codeChangedElsewhere ifTrue: >> [^ self hasEditingConflicts: true]. >> aSymbol == #saveContents ifTrue: >> [^self controller saveContentsInFile]. >> aSymbol == #close ifTrue: >> [^self topView controller closeAndUnscheduleNoTerminate]. >> aSymbol == #acceptChanges ifTrue: >> [^ self controller accept]. >> aSymbol == #revertChanges ifTrue: >> [^ self controller cancel].! |
Free forum by Nabble | Edit this page |