[squeak-dev] The Trunk: Morphic-eem.1784.mcz

Eliot Miranda eliot.miranda at gmail.com
Mon Oct 25 18:31:20 UTC 2021


On Fri, Oct 22, 2021 at 1:53 AM Marcel Taeumel <marcel.taeumel at hpi.de>
wrote:

> Hi Eliot --
>
> Thank you for the fix.
>
> If you want me to follow to the formatting guidelines in Compiler & Co., I
> would appreciate it that you do so in Morphic & Co.
>
> You changed the entire format of the method, which makes it challenging
> for me to review your fix.
>
> Best,
> Marcel
>
> P.S.: Nope, the coding style you use in Compiler & Co. is just different,
> not better. ;-)
>

It is backed up by a book by a leading author which includes justifications
of all stylistic decisions.  So I assert that it is better in being
carefully considered.

To expand a bit, Smalltalk is an expression based language; every statement
except for a method's message pattern, temporary declarations and pragmas
are values.  There is no statement which is not a value.  Formatting using
curly bracket patterns (left bracket at the end of a line) (in mine and
other's opinion) obscures this, and is the import of a style used in
statement oriented languages.  [ & ] are not equivalent to {  and } in
curly bracket languages [ and ] define an object (a block), not merely
delimit a purely syntactic entity, a sequence of statements.  And for
visual thinkers rectangular block is an essential pattern.

I apologize for the distress caused.  However, I do think that rectangular
block is a vastly superior style to what one might call "C with
square brackets".  It reflects the fact that blocks are objects, uses far
less vertical real estate, and jumps out at visual thinkers.


>
> Am 17.10.2021 20:34:48 schrieb commits at source.squeak.org <
> commits at source.squeak.org>:
> Eliot Miranda uploaded a new version of Morphic to project The Trunk:
> http://source.squeak.org/trunk/Morphic-eem.1784.mcz
>
> ==================== Summary ====================
>
> Name: Morphic-eem.1784
> Author: eem
> Time: 17 October 2021, 11:34:29.99006 am
> UUID: 7e3f944d-18fc-4a6f-bb86-03c8037ec775
> Ancestors: Morphic-mt.1783
>
> Text editing bug fixes.
> A paragraph may not have been composed when interrogated for test and/or
> graphic coordinates.
>
> A TextEditor for a Transcript may have no history but still be asked to
> openTypeInFor:/closeTypeIn:.
>
> =============== Diff against Morphic-mt.1783 ===============
>
> Item was changed:
> ----- Method: NewParagraph>>fastFindFirstLineSuchThat: (in category
> 'private') -----
> fastFindFirstLineSuchThat: lineBlock
> "Perform a binary search of the lines array and return the index
> of the first element for which lineBlock evaluates as true.
> This assumes the condition is one that goes from false to true for
> increasing line numbers (as, eg, yval > somey or start char > somex).
> If lineBlock is not true for any element, return size+1."
> + lines ifNil:
> + [self composeAll].
> -
> ^lines
> findBinaryIndex: [ :each |
> (lineBlock value: each)
> ifTrue: [ -1 ]
> ifFalse: [ 1 ] ]
> ifNone: [ :lower :upper | upper ]!
>
> Item was changed:
> ----- Method: TextEditor>>closeTypeIn (in category 'typing support') -----
> closeTypeIn
> "See comment in openTypeIn. It is important to call closeTypeIn before
> executing
> any non-typing key, making a new selection, etc. It is called
> automatically for
> menu commands."
>
> | begin stop |
> + beginTypeInIndex ifNotNil:
> + [begin := beginTypeInIndex.
> - beginTypeInIndex ifNotNil: [
> - begin := beginTypeInIndex.
> stop := self stopIndex.
>
> + self history ifNotNil:
> + [:myHistory|
> + myHistory current
> + contentsAfter: (stop <= begin
> + ifTrue: [self nullText]
> + ifFalse: [paragraph text copyFrom: begin to: stop-1]);
> + intervalAfter: (stop to: stop-1);
> + intervalBetween: (stop < begin
> + ifTrue: [stop to: stop-1]
> + ifFalse: [begin to: stop-1]);
> + messageToUndo: (Message selector: #undoAndReselect);
> + messageToRedo: (Message selector: #redoAndReselect).
> +
> + myHistory finishRemember].
> - self history current
> - contentsAfter: (stop <= begin
> - ifTrue: [self nullText]
> - ifFalse: [paragraph text copyFrom: begin to: stop-1]);
> - intervalAfter: (stop to: stop-1);
> - intervalBetween: (stop < begin
> - ifTrue: [stop to: stop-1]
> - ifFalse: [begin to: stop-1]);
> - messageToUndo: (Message selector: #undoAndReselect);
> - messageToRedo: (Message selector: #redoAndReselect).
> -
> - self history finishRemember.
>
> beginTypeInIndex := nil]!
>
> Item was changed:
> ----- Method: TextEditor>>openTypeInFor: (in category 'typing support')
> -----
> openTypeInFor: editType
> "Set up UndoSelection to null text (to be added to by readKeyboard and
> backTo:),
> beginTypeInBlock to keep track of the leftmost backspace, and
> UndoParameter to tally
> how many deleted characters were backspaced over rather than 'cut'.
> You can't undo typing until after closeTypeIn."
>
> + beginTypeInIndex ifNil:
> + [beginTypeInIndex := self startIndex.
> + self history ifNotNil:
> + [:myHistory|
> + myHistory beginRemember:
> + (TextEditorCommand new
> + type: editType;
> + contentsBefore: (self hasSelection ifTrue: [self selection] ifFalse:
> [self nullText]);
> + intervalBefore: (beginTypeInIndex to: self stopIndex-1)
> + yourself)]]!
> - beginTypeInIndex ifNil: [
> - beginTypeInIndex := self startIndex.
> - self history beginRemember: (TextEditorCommand new
> - type: editType;
> - contentsBefore: (self hasSelection ifTrue: [self selection] ifFalse:
> [self nullText]);
> - intervalBefore: (beginTypeInIndex to: self stopIndex-1)
> - yourself)].!
>
>
>
>

-- 
_,,,^..^,,,_
best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20211025/f99cad5d/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 124647 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20211025/f99cad5d/attachment-0001.png>


More information about the Squeak-dev mailing list