Hi Sven,

> On Mar 8, 2018, at 9:55 AM, Sven Van Caekenberghe <[email protected]> wrote:
> 
> 
> 
>> On 8 Mar 2018, at 17:58, Eliot Miranda <[email protected]> wrote:
>> 
>> Hi Stef,
>> 
>> following on from Sean, (+1000 for using ordinary quotes)
>> 
>> ’string’ collection of characters => ’string’ sequence of characters
>> $a, Character space Two ways to create characters => $a, Character space two 
>> ways to denote characters (or two ways to write characters; all other 
>> explanations in this list are not capitalized; this shouldn't be either)
>> exp1. exp2 expression separator => expr1. expr2 statement separator
>> ; message cascade => expr doThis ; doThat   semicolon - message cascade 
>> (c.f. exp1. exp2 expression separator)
>> ^ expr caret - returns a result from a method => ^ expr caret - return a 
>> result from a method (or, ParcPlace preference, answer a result from a 
>> method, since we're sending messages here)
>> 
>> ...
>> A unary message is one with no arguments. => A unary message has no 
>> arguments. (c.f. A binary message takes only one argument ...)
>> ...
>> Set new add: 4; add: 4 ; yourself ~> aSet => Set new add: 4; add: 4 ; 
>> yourself ~> aSet(4)
>> Dictionary new at: #a put: 'Alpha' ; yourself a Dictionary => Dictionary new 
>> at: #a put: 'Alpha' ; yourself a Dictionary(#a->'Alpha' )
>> 
>> and then in the Files and Stream section I would give two more examples of 
>> exactly the same sequence that use the convenience APIs.  This is the 
>> existing text:
>> 
>>    work := FileSystem disk workingDirectory.
>>    stream := (work / ’foo.txt’) writeStream.
>>    stream nextPutAll: ’Hello World’.
>>    stream close.
>>    stream := (work / ’foo.txt’) readStream.
>>    stream contents.                                     ~> 'Hello World'
>>    stream close.
>> 
>> I would make it read
>> 
>>    work := FileSystem disk workingDirectory.
>>    stream := (work / ’foo.txt’) writeStream.
>>    stream nextPutAll: ’Hello World’.
>>    stream close.
>>    stream := (work / ’foo.txt’) readStream.
>>    stream contents.                                     ~> 'Hello World'
>>    stream close.
>> 
>>    or, more simply
>> 
>>    work := FileSystem disk workingDirectory.
>>    (work / ’foo.txt’) writeStreamDo: [ :fileStream | fileStream nextPutAll: 
>> ’Hello World’ ].
>>    (work / ’foo.txt’) readStreamDo: [ :fileStream | fileStream contents]     
>>                        ~> 'Hello World'
>> 
>>    or, more simply still
>> 
>>    work := FileSystem disk workingDirectory.
>>    (work / ’foo.txt’) writeStreamDo: [ :fileStream | fileStream nextPutAll: 
>> ’Hello World’ ].
>>    (work / ’foo.txt’) contents                                               
>>                                               ~> 'Hello World'
> 
> file := FileSystem disk workingDirectory / 'foo' , 'txt'.
> file ensureDelete.
> file writeStreamDo: [ :fileStream | fileStream nextPutAll: 'Hello World' ].
> file contents.
> file delete.
> 
> (to make it re-entrant and a bit more concise)

that suggests 

file := FileSystem disk workingDirectory / 'foo' , 'txt'.
file newWriteStreamDo: [ :fileStream | fileStream nextPutAll: 'Hello World' ].
file contents.
file delete.

where newWriteStreamDo: includes the file ensureDelete, or better still a 
truncation, which saves the effort of deletion but (I *think*) has the same 
effect.

> 
> +1e10 for plain single quotes, VERY important.
> 
>> or if you can't make it fit, just give the last version
>> 
>> Finally, this seems to have fallen off the end:
>> A simple, uniform and powerful model
>> Pharo has a simple dynamically-typed object model:
>> 
>> Perhaps shrink the picture of the browser.  You can save three lines by 
>> writing 
>>    OrderedCollection new
>>        add: 1;
>>        add: 2;
>>        add: 3.
>> 
>> as OrderedCollection new add: 1; add: 2; add: 3.
>> And another by writing 2=2 ifTrue: [ Error signal: ’Help’ ]. on one line.
>> 
>> HTH
>> 
>> On Fri, Apr 8, 2016 at 12:56 PM, stepharo <[email protected]> wrote:
>> new cheatsheet for Pharo syntax.
>> Any feedback is welcome
>> 
>> Stef
>> 
>> 
>> 
>> -- 
>> _,,,^..^,,,_
>> best, Eliot
> 
> 

Reply via email to