On 08/04/2016 21:56, stepharo wrote:
new cheatsheet for Pharo syntax. Any feedback is welcome
Hi, The screen seems to be from Pharo 1 no?
Stef
-- Cyril Ferlicot http://www.synectique.eu 165 Avenue Bretagne Lille 59000 France
It looks good. I might mention that most data structures are 1 indexed as most other languages tend to be 0 indexed and that throws people new to the language. On Fri, Apr 8, 2016 at 3:58 PM stepharo <stepharo@free.fr> wrote:
new cheatsheet for Pharo syntax. Any feedback is welcome
Stef
On 08 Apr 2016, at 22:08, J.F. Rick <self@je77.com> wrote:
It looks good. I might mention that most data structures are 1 indexed as most other languages tend to be 0 indexed and that throws people new to the language.
Actually the others are wrong ;-) Seriously, in Mathematics 1 based indexing is normal, remember vectors, matrices, series, ... Normal people (non computer nerds, the 99%) talk about the first element with number 1. Since we are simpler and more logical, a cheat sheet should not confuse people by describing what we are not.
On Fri, Apr 8, 2016 at 3:58 PM stepharo <stepharo@free.fr> wrote: new cheatsheet for Pharo syntax. Any feedback is welcome
Stef
On 8 April 2016 at 22:57, Sven Van Caekenberghe <sven@stfx.eu> wrote:
Since we are simpler and more logical, a cheat sheet should not confuse people by describing what we are not.
I beg to disagree. "Simpler and more logical" is just your biased point of view; fact is, zero-based indexing is just more widespread in programming languages. I would be happy to be proven wrong about that, but I seriously doubt most people that come to Smalltalk have never been exposed to programming before. It's not unreasonable to assume that they've started programming in any one of the most popular languages these days, and that that language is zero-indexed. So mentioning that in Smalltalk the first element is indeed at index 1 is pretty essential, if just to lift the ambiguity. -- Damien Pollet type less, do more [ | ] http://people.untyped.org/damien.pollet
On Sat, Apr 9, 2016 at 6:16 AM, Damien Pollet <damien.pollet@gmail.com> wrote:
On 8 April 2016 at 22:57, Sven Van Caekenberghe <sven@stfx.eu> wrote:
Since we are simpler and more logical, a cheat sheet should not confuse people by describing what we are not.
I beg to disagree. "Simpler and more logical" is just your biased point of view; fact is, zero-based indexing is just more widespread in programming languages.
I would be happy to be proven wrong about that, but I seriously doubt most people that come to Smalltalk have never been exposed to programming before. It's not unreasonable to assume that they've started programming in any one of the most popular languages these days, and that that language is zero-indexed. So mentioning that in Smalltalk the first element is indeed at index 1 is pretty essential, if just to lift the ambiguity.
+1. But to follow Sven's point exactly. We don't need to say we are "not 0 based", just that we are "1 based". cheers -ben
I think that it could be interesting to use it also on a simple HTML page for the Pharo web site. This document can be put in the main menu ("Beginners" ?) just before "Documentation". It's really cool to have a synthesis document for the newcomers. 2016-04-09 8:09 GMT+02:00 Ben Coman <btc@openinworld.com>:
On Sat, Apr 9, 2016 at 6:16 AM, Damien Pollet <damien.pollet@gmail.com> wrote:
On 8 April 2016 at 22:57, Sven Van Caekenberghe <sven@stfx.eu> wrote:
Since we are simpler and more logical, a cheat sheet should not confuse people by describing what we are not.
I beg to disagree. "Simpler and more logical" is just your biased point of view; fact is, zero-based indexing is just more widespread in programming languages.
I would be happy to be proven wrong about that, but I seriously doubt most people that come to Smalltalk have never been exposed to programming before. It's not unreasonable to assume that they've started programming in any one of the most popular languages these days, and that that language is zero-indexed. So mentioning that in Smalltalk the first element is indeed at index 1 is pretty essential, if just to lift the ambiguity.
+1. But to follow Sven's point exactly. We don't need to say we are "not 0 based", just that we are "1 based".
cheers -ben
On Apr 9, 2016 9:54 AM, "olivier auverlot" <olivier.auverlot@gmail.com> wrote:
I think that it could be interesting to use it also on a simple HTML
page for the Pharo web site. This document can be put in the main menu ("Beginners" ?) just before "Documentation".
It's really cool to have a synthesis document for the newcomers.
I still have a little Squeak booklet that we could redo for Pharo. It was very useful when I was learning. Phil
2016-04-09 8:09 GMT+02:00 Ben Coman <btc@openinworld.com>:
On Sat, Apr 9, 2016 at 6:16 AM, Damien Pollet <damien.pollet@gmail.com>
wrote:
On 8 April 2016 at 22:57, Sven Van Caekenberghe <sven@stfx.eu> wrote:
Since we are simpler and more logical, a cheat sheet should not
confuse
people by describing what we are not.
I beg to disagree. "Simpler and more logical" is just your biased point of view; fact is, zero-based indexing is just more widespread in programming languages.
I would be happy to be proven wrong about that, but I seriously doubt most people that come to Smalltalk have never been exposed to programming before. It's not unreasonable to assume that they've started programming in any one of the most popular languages these days, and that that language is zero-indexed. So mentioning that in Smalltalk the first element is indeed at index 1 is pretty essential, if just to lift the ambiguity.
+1. But to follow Sven's point exactly. We don't need to say we are "not 0 based", just that we are "1 based".
cheers -ben
Le 9/4/16 10:04, philippe.back@highoctane.be a écrit :
On Apr 9, 2016 9:54 AM, "olivier auverlot" <olivier.auverlot@gmail.com <mailto:olivier.auverlot@gmail.com>> wrote:
I think that it could be interesting to use it also on a simple
HTML page for the Pharo web site. This document can be put in the main menu ("Beginners" ?) just before "Documentation".
It's really cool to have a synthesis document for the newcomers.
I still have a little Squeak booklet that we could redo for Pharo. It was very useful when I was learning.
I'm about to update the syntax squeak flyers we did a long ago. Stef
Phil
2016-04-09 8:09 GMT+02:00 Ben Coman <btc@openinworld.com
<mailto:btc@openinworld.com>>:
On Sat, Apr 9, 2016 at 6:16 AM, Damien Pollet
<damien.pollet@gmail.com <mailto:damien.pollet@gmail.com>> wrote:
On 8 April 2016 at 22:57, Sven Van Caekenberghe <sven@stfx.eu <mailto:sven@stfx.eu>> wrote:
Since we are simpler and more logical, a cheat sheet should not
confuse
people by describing what we are not.
I beg to disagree. "Simpler and more logical" is just your biased point of view; fact is, zero-based indexing is just more widespread in programming languages.
I would be happy to be proven wrong about that, but I seriously doubt most people that come to Smalltalk have never been exposed to programming before. It's not unreasonable to assume that they've started programming in any one of the most popular languages these days, and that that language is zero-indexed. So mentioning that in Smalltalk the first element is indeed at index 1 is pretty essential, if just to lift the ambiguity.
+1. But to follow Sven's point exactly. We don't need to say we are "not 0 based", just that we are "1 based".
cheers -ben
On Sat, Apr 9, 2016 at 3:52 PM, olivier auverlot <olivier.auverlot@gmail.com> wrote:
I think that it could be interesting to use it also on a simple HTML page for the Pharo web site. This document can be put in the main menu ("Beginners" ?) just before "Documentation".
It's really cool to have a synthesis document for the newcomers.
I came across this a while ago and found it quite interesting... http://www2.ing.unipi.it/~a009435/issw/extra/readingSmalltalk.pdf
Le 08/04/2016 22:08, J.F. Rick a écrit :
It looks good. I might mention that most data structures are 1 indexed as most other languages tend to be 0 indexed and that throws people new to the language.
I use Pharo since 1 year now and I had to use indexes only 3-4 times. I think it is more important to say that Pharo have Collections with an awesome API. -- Cyril Ferlicot http://www.synectique.eu 165 Avenue Bretagne Lille 59000 France
@cyril +1 Le 9 avr. 2016 10:56 AM, "Cyril Ferlicot D." <cyril.ferlicot@gmail.com> a écrit :
Le 08/04/2016 22:08, J.F. Rick a écrit :
It looks good. I might mention that most data structures are 1 indexed as most other languages tend to be 0 indexed and that throws people new to the language.
I use Pharo since 1 year now and I had to use indexes only 3-4 times. I think it is more important to say that Pharo have Collections with an awesome API.
-- Cyril Ferlicot
165 Avenue Bretagne Lille 59000 France
On 09-04-16 10:55, Cyril Ferlicot D. wrote:
I use Pharo since 1 year now and I had to use indexes only 3-4 times.
Probably on day 1 and 2 :) The problem is that people new to Smalltalk have a background. If they have programming experience, it is likely with a language where indexes are important. Finding out how and when to avoid using them takes time to learn. And that is exactly when they need the cheatsheet most. Stephan
Yes you are right. We have 2 students (3rd Year at University) here that have been exposed only to C or Java and they are totally index-intoxicated ... They can't reason on collections. Difficult for them to change their habits. Sent from my iPhone
On 9 avr. 2016, at 11:51, Stephan Eggermont <stephan@stack.nl> wrote:
On 09-04-16 10:55, Cyril Ferlicot D. wrote: I use Pharo since 1 year now and I had to use indexes only 3-4 times.
Probably on day 1 and 2 :) The problem is that people new to Smalltalk have a background. If they have programming experience, it is likely with a language where indexes are important. Finding out how and when to avoid using them takes time to learn. And that is exactly when they need the cheatsheet most.
Stephan
On 09/04/2016 10:59, serge.stinckwich@gmail.com wrote:
Yes you are right. We have 2 students (3rd Year at University) here that have been exposed only to C or Java and they are totally index-intoxicated ... They can't reason on collections. Difficult for them to change their habits.
Sent from my iPhone
Surely learning Java now should not be index based - the for loop is enumerated and it has the filters maps etc. e.g. <http://zeroturnaround.com/rebellabs/java-8-explained-applying-lambdas-to-jav...> (so bad teaching?) and C as a first language I would have thought not a good idea either. -- Mark
I agree that enumeration is more useful but it wouldn't be bad to have something in there to indicate the 1-index nature, such as *'abcd' at: 2* will result in $b That's all I was suggesting. Actually, having some cheat sheet on basic enumeration wouldn't be bad as that is a real strength of Smalltalk. Mention and illustrate what do: collect: and select: do. Then mention that there are other ones like count: and sum:. Cheers, Jeff On Sat, Apr 9, 2016 at 4:57 AM Cyril Ferlicot D. <cyril.ferlicot@gmail.com> wrote:
Le 08/04/2016 22:08, J.F. Rick a écrit :
It looks good. I might mention that most data structures are 1 indexed as most other languages tend to be 0 indexed and that throws people new to the language.
I use Pharo since 1 year now and I had to use indexes only 3-4 times. I think it is more important to say that Pharo have Collections with an awesome API.
-- Cyril Ferlicot
165 Avenue Bretagne Lille 59000 France
Hi Stef, "boolean objects" => "the boolean objects" "the receiver, in the superclass context" => "ditto, for accessing overridden inherited methods" "the current invocation on the call stack" => "the current method or block activation" _,,,^..^,,,_ (phone)
On Apr 11, 2016, at 11:58 PM, stepharo <stepharo@free.fr> wrote:
new syntaxsheet
<pharoCheatSheet.pdf>
In the "common constructs" conditionals and iterations tables, the Java appears on the left and the Smalltalk on the right. In other tables the Smalltalk occurs on the left and the explanation appears on the right. Hence, in the conditionals and iterations tables, put the Java on the right. Personally I very much /would/ include ". statement separator" in the reserved syntactic constructs table. I might try and split the table into "syntax" ( "comment" ; . and ^ ) and "object constructors" tables (everything else). _,,,^..^,,,_ (phone)
On Apr 11, 2016, at 11:58 PM, stepharo <stepharo@free.fr> wrote:
new syntaxsheet
<pharoCheatSheet.pdf>
Hi eliot I took everything into account except the Personally I very much /would/ include ". statement separator" in the reserved syntactic constructs table. I might try and split the table into "syntax" ( "comment" ; . and ^ ) and "object constructors" tables (everything else). I have to digest it and now I should finish some other work for the mooc. I'm fighting a lot with the space :) Stef Le 12/4/16 13:35, Eliot Miranda a écrit :
In the "common constructs" conditionals and iterations tables, the Java appears on the left and the Smalltalk on the right. In other tables the Smalltalk occurs on the left and the explanation appears on the right. Hence, in the conditionals and iterations tables, put the Java on the right.
Personally I very much /would/ include ". statement separator" in the reserved syntactic constructs table. I might try and split the table into "syntax" ( "comment" ; . and ^ ) and "object constructors" tables (everything else).
_,,,^..^,,,_ (phone)
On Apr 11, 2016, at 11:58 PM, stepharo <stepharo@free.fr> wrote:
new syntaxsheet
<pharoCheatSheet.pdf>
Hello Is the cheat sheet http://files.pharo.org/media/pharoCheatSheet.pdf up to date for Pharo 6.1 and Pharo 7? In particular - the references to the main web sites, are they still OK? MainWebSites - Codehosting http://smalltalkhub.com - Questions http://discord.gg/Sj2rhxn - Blog http://pharoweekly.wordpress.com - Contributors http://pharo.org/about - Topics http://topics.pharo.org - Consortium http://consortium.pharo.org - Association http://association.pharo.org Pharo Books Pharo books are available at: http://books.pharo.org Pharo By Example, Deep into Pharo, Enterprise Pharo: a Web Perspective, Numerical Methods in Pharo, TinyBlog Tutorial, Dynamic Web Development in Seaside (http://book.seaside.st) More books http://stephane.ducasse.free.fr/FreeBooks --Hannes On 4/12/16, stepharo <stepharo@free.fr> wrote:
Hi eliot
I took everything into account except the
Personally I very much /would/ include ". statement separator" in the reserved syntactic constructs table. I might try and split the table into "syntax" ( "comment" ; . and ^ ) and "object constructors" tables (everything else).
I have to digest it and now I should finish some other work for the mooc. I'm fighting a lot with the space :)
Stef
Le 12/4/16 13:35, Eliot Miranda a écrit :
In the "common constructs" conditionals and iterations tables, the Java appears on the left and the Smalltalk on the right. In other tables the Smalltalk occurs on the left and the explanation appears on the right. Hence, in the conditionals and iterations tables, put the Java on the right.
Personally I very much /would/ include ". statement separator" in the reserved syntactic constructs table. I might try and split the table into "syntax" ( "comment" ; . and ^ ) and "object constructors" tables (everything else).
_,,,^..^,,,_ (phone)
On Apr 11, 2016, at 11:58 PM, stepharo <stepharo@free.fr> wrote:
new syntaxsheet
<pharoCheatSheet.pdf>
normally yes. On Thu, Mar 8, 2018 at 10:48 AM, H. Hirzel <hannes.hirzel@gmail.com> wrote:
Hello
Is the cheat sheet http://files.pharo.org/media/pharoCheatSheet.pdf
up to date for Pharo 6.1 and Pharo 7?
In particular - the references to the main web sites, are they still OK?
MainWebSites - Codehosting http://smalltalkhub.com - Questions http://discord.gg/Sj2rhxn - Blog http://pharoweekly.wordpress.com - Contributors http://pharo.org/about - Topics http://topics.pharo.org - Consortium http://consortium.pharo.org - Association http://association.pharo.org
Pharo Books
Pharo books are available at: http://books.pharo.org Pharo By Example, Deep into Pharo, Enterprise Pharo: a Web Perspective, Numerical Methods in Pharo, TinyBlog Tutorial, Dynamic Web Development in Seaside (http://book.seaside.st) More books http://stephane.ducasse.free.fr/FreeBooks
--Hannes
On 4/12/16, stepharo <stepharo@free.fr> wrote:
Hi eliot
I took everything into account except the
Personally I very much /would/ include ". statement separator" in the reserved syntactic constructs table. I might try and split the table into "syntax" ( "comment" ; . and ^ ) and "object constructors" tables (everything else).
I have to digest it and now I should finish some other work for the mooc. I'm fighting a lot with the space :)
Stef
Le 12/4/16 13:35, Eliot Miranda a écrit :
In the "common constructs" conditionals and iterations tables, the Java appears on the left and the Smalltalk on the right. In other tables the Smalltalk occurs on the left and the explanation appears on the right. Hence, in the conditionals and iterations tables, put the Java on the right.
Personally I very much /would/ include ". statement separator" in the reserved syntactic constructs table. I might try and split the table into "syntax" ( "comment" ; . and ^ ) and "object constructors" tables (everything else).
_,,,^..^,,,_ (phone)
On Apr 11, 2016, at 11:58 PM, stepharo <stepharo@free.fr> wrote:
new syntaxsheet
<pharoCheatSheet.pdf>
#(4 3 1) at: 3 put: 6 => either #(4 3 1) copy at: 3 put: 6 or { 4. 3. 1} at: 3 put: 6 Sooner or later literals are going to be immutable and then #(4 3 1) at: 3 put: 6 will raise an exception. _,,,^..^,,,_ (phone)
On Apr 11, 2016, at 11:58 PM, stepharo <stepharo@free.fr> wrote:
new syntaxsheet
<pharoCheatSheet.pdf>
Le 12/4/16 13:39, Eliot Miranda a écrit :
#(4 3 1) at: 3 put: 6 => either
#(4 3 1) copy at: 3 put: 6
or
{ 4. 3. 1} at: 3 put: 6
Sooner or later literals are going to be immutable and then #(4 3 1) at: 3 put: 6 will raise an exception.
eager to have that :) I used the copy.
_,,,^..^,,,_ (phone)
On Apr 11, 2016, at 11:58 PM, stepharo <stepharo@free.fr> wrote:
new syntaxsheet
<pharoCheatSheet.pdf>
"a debugger, a workspace and object inspectors" => "compiler, debugger, workspace, object inspectors" and maybe drop "object" then it flows into "and much, much more". That the compiler is implemented in Smalltalk is v important, IMO. _,,,^..^,,,_ (phone)
On Apr 11, 2016, at 11:58 PM, stepharo <stepharo@free.fr> wrote:
new syntaxsheet
<pharoCheatSheet.pdf>
Thanks great. As we are looking language cheatsheet, a few minutes ago, I was reading an old news[1] about OCaml[2], here its cheatsheet[3]. It is said to be a great language, supported by INRIA as well, with strong type. But Pharo makes me fell more comfortable when complexity need to be handled. Hilaire [1] http://linuxfr.org/redaction/news/ocaml-4-03 [2] http://ocaml.org/ [3] http://www.ocamlpro.com/files/ocaml-lang.pdf Le 08/04/2016 21:56, stepharo a écrit :
new cheatsheet for Pharo syntax.
-- Dr. Geo http://drgeo.eu
On Sat, Apr 9, 2016 at 3:56 AM, stepharo <stepharo@free.fr> wrote:
new cheatsheet for Pharo syntax. Any feedback is welcome
So I really went to town and picked the eyes out of it...
#(abc 123) literal array with the symbol #abc and the number 123
This one surprised me. I had to test it to check it was true. It doesn't seem very consistent. Regardless of whether we *can* do it like that, it would be more intuitive to be #(123 #abc). But really, should we even allow it?
12 2r1100 16rC twelve (decimal, binary, hexadecimal) floating-point numbers
The correspondence of the '2' of the '12 very close to the '2' of the '2r' is a bit awkward. Also I think we can take decimal numbers for granted and its easier for people to immediately identify A=10 rather than C=12, and lets not leave the meaning of 'r' implicit. So perhaps use.... 2r1010 16rA binary and hexadecimal radix of 10
{foo . 3 + 2}
Perhaps move the "declaration of two temporary variables" above this, so foo it properly introduce foo as a variable rather than leaving it implicit. Otherwise from the literal array example it might be inferred that foo is a symbol. Also, the "expression separator" should be introduced before it is used in the dynamic array. So perhaps the dynamic array (or all array) examples should be closer to the end.
A method is invoked by sending a message to an object, the message receiver; the message returns an object.
A message is an identifier for which objects provide methods of implementation. A method is invoked by sending a message to an object. The object is the /receiver/ of the message. The message returns an object.
Messages syntax mimics natural language
Message syntax mimics natural language
Pharo: aColor r: 0.2 g: 0.3 b: 0
This is not very natural language. We only need one Java/Pharo example. Delete this one.
Array new
You would never(?) really use that line. So lets not mislead a newcomer who might try it and get frustrated why they can't add items to it. OrderedCollection new is described later, so here perhaps instead use... 2 squared The receiver of the squared message is the object 2, with the object 4 returned.
A keyword message can take one or more arguments that are inserted in the message name.
A keyword message can take one or more arguments that are interspersed through the message name. (Put the example of this first, i.e. #to:by: before #allButFirst:
Precedence
Message Precedence
Parentheses > unary > binary > keyword,
Is too concise. I know the answer but I still feel awkward decoding that line. Better... Message sending order of precedence is: parentheses, unary, binary, keyword, left to right.
(10 between: 1 and: 2 + 4 * 3) not
Might be better to one more unary message... (10 between: 1 and: 2 + 4 * 3 negated) not The unary #negated message inside the parentheses is sent first, then #+ as the left most binary message, followed by #*. Then keyword message #between:and: is sent, and finally #not.
The rule suffers no exception: operators
The rule suffers no exception. Operators
so 2 + 4 * 3 reads left-to-right and gives 18, not 14!
so 2 + 4 * 3 reads left-to-right and gives 18, not 14! Note, comparison operators like equals = is just binary messages, so... 1 * 3 = 3 produces boolean object true but 3 = 3 * 1 produces an error, since a boolean object does not understand multiplication. Hint, while beginning with Pharo, make liberal us of parentheses in calculations to make precedence explicit and thus easy to observe.
OrderedCollection new add: #abc; add: #def; add: #ghi.
Rather than just mentioning needing to send #yourself in the text, show the pattern more explicitly by putting it in the example... OrderedCollection new add: #abc; add: #def; add: #ghi; yourself. The message new is sent to OrderedCollection which results in a new collection to which three add: messages are sent. The value of the whole message cascade is the value of the last message sent, so without #yourself this would be the symbol #ghi. With #yourself, the return value is {#abc. #def. #ghi}
Blocks are objects containing code that is executed on demand, (anonymous functions). They are the basis for control structures like conditionals and loops.
Blocks are objects, that contain code to be executed on demand (anonymous functions). They defined by square brackets and are the basis for control structures like conditionals and loops.
2 = 2 ifTrue: [Error signal: âHelpâ].
Lets not mix in additional concepts. How about... 2 = 2 ifTrue: [self inform: 'Equal']
The first example sends the message ifTrue: to the boolean true (computed from 2 = 2 ) with a block as argument.
From 2 = 2 comes the boolean object true, to which the #ifTrue: message is sent with the block as argument. The object true always evaluates #ifTrue: arguments, thus the text "Equal' displays on the screen.
As a result, Hello World! is printed.
As a result, Hello World! is printed. in the Transcript window (which you from the World > Tools menu)
Pharo is a live programming environment: you can modify your objects and your code while your program is executing.
⢠and much, much more!
There doesn't seem much use in that line hanging on its lonesome at the top of a column
When a protocol name starts with a *, methods of this protocol belong to a different package
A protocol name starting with a * indicates methods belonging to a different package.
To add a package: first column + menu add package
To add a package, right-click lower down in the Packages pane. (If they right-click near the top they wont get that option - something I find annoying)
To add a class, edit the proposed template!
To add a class, select a package and edit the proposed template. (its not that exciting to need an exclamation mark :)
Counter new . initialize super initialize count := 0
It looks like the first line is part of the rest of the code sample. Also this should be moved beneath the Methods subheading.
Methods are public and virtual. There are always looked up in
Methods are public and virtual. They are always looked up in
Class methods follow the same dynamic lookup than instance
Class methods follow the same dynamic lookup as instance cheers -ben
stepharo wrote
new cheatsheet for Pharo syntax. Any feedback is welcome
Looks great! (and surprise, it covers much more than just syntax). A few observations: 1. The code examples have smart quotes. This can create confusion. If it's not too much trouble, copy/pasteable-into-Pharo single quotes would be better. 2. Under "Pharo: a Live Programming Environment" ends with "⦠program is executing. All". I guess that sentence is continued on the other side? If so, it might be clearer to end with (over) and move the All to the other side with the rest of the sentence. 3. The following example reminded me of the joy of Pharo's uniformity and expressivity vs. e.g. Java or C++ - #1:`d.put("1", "Chocolate");` vs. #2: `d at: '1' put: 'Chocolate'`. Experience of #1 - what was the order of the parameters? Do I need a dot or arrow? [but then I get to sit back and feel superior that I am one of the few "gurus" to have mastered an incomprehensible system] vs. Experience of #2 - "hey, d. please at 1 put Chocolate. Thanks" 4. Maybe too much detail, but where it says: "Counter >> initialize is a notation to indicate that the following text is the content of the method initialize in the class Counter." I personally find it pretty cool that adding $# i.e. `Counter >> #initialize` makes it executable code, especially now that we have GT tools which will open up a handful of domain views on the method! ----- Cheers, Sean -- Sent from: http://forum.world.st/Pharo-Smalltalk-Developers-f1294837.html
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' 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 <stepharo@free.fr> wrote:
new cheatsheet for Pharo syntax. Any feedback is welcome
Stef
-- _,,,^..^,,,_ best, Eliot
On 8 Mar 2018, at 17:58, Eliot Miranda <eliot.miranda@gmail.com> 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) +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 <stepharo@free.fr> wrote: new cheatsheet for Pharo syntax. Any feedback is welcome
Stef
-- _,,,^..^,,,_ best, Eliot
Hi Sven,
On Mar 8, 2018, at 9:55 AM, Sven Van Caekenberghe <sven@stfx.eu> wrote:
On 8 Mar 2018, at 17:58, Eliot Miranda <eliot.miranda@gmail.com> 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 <stepharo@free.fr> wrote: new cheatsheet for Pharo syntax. Any feedback is welcome
Stef
-- _,,,^..^,,,_ best, Eliot
2018-03-08 19:44 GMT+01:00 Eliot Miranda <eliot.miranda@gmail.com>:
Hi Sven,
On Mar 8, 2018, at 9:55 AM, Sven Van Caekenberghe <sven@stfx.eu> wrote:
On 8 Mar 2018, at 17:58, Eliot Miranda <eliot.miranda@gmail.com> 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.
Hi Eliot, not exactly the same effect wrt file access rights.
+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 <stepharo@free.fr> wrote:
new cheatsheet for Pharo syntax.
Any feedback is welcome
Stef
--
_,,,^..^,,,_
best, Eliot
participants (18)
-
Ben Coman -
Cyril Ferlicot D. -
Cyril Ferlicot Delbecque -
Damien Pollet -
Eliot Miranda -
H. Hirzel -
Hilaire -
J.F. Rick -
Mark Bestley -
Nicolas Cellier -
olivier auverlot -
philippe.back@highoctane.be -
Sean P. DeNigris -
serge.stinckwich@gmail.com -
Stephan Eggermont -
Stephane Ducasse -
stepharo -
Sven Van Caekenberghe